ZQuest Classic Coverage Report


Directory: src/
File: src/base/qst.cpp
Date: 2025-07-30 21:27:58
Exec Total Coverage
Lines: 9474 13081 72.4%
Functions: 114 144 79.2%
Branches: 7173 12177 58.9%

Line Branch Exec Source
1 #include "allegro/file.h"
2 #include "base/flags.h"
3 #include "base/general.h"
4 #include "base/util.h"
5 #include "base/version.h"
6 #include "base/zapp.h"
7 #include "base/qrs.h"
8 #include "base/cpool.h"
9 #include "base/autocombo.h"
10 #include "base/packfile.h"
11 #include "base/dmap.h"
12 #include "base/combo.h"
13 #include "base/msgstr.h"
14 #include "base/flags.h"
15 #include <bit>
16 #include <filesystem>
17 #include <memory>
18 #include <optional>
19 #include <stdio.h>
20 #include <cstring>
21 #include <string>
22 #include <map>
23 #include <vector>
24 #include <assert.h>
25 #include <fmt/format.h>
26
27
28 #include "fmt/core.h"
29 #include "base/zc_alleg.h"
30 #include "base/zdefs.h"
31 #include "base/colors.h"
32 #include "tiles.h"
33 #include "base/zsys.h"
34 #include "base/qst.h"
35 #include "defdata.h"
36 #include "subscr.h"
37 #include "sfx.h"
38 #include "base/md5.h"
39 #include "zc/replay.h"
40 #include "zc/zelda.h"
41 #include "zinfo.h"
42 #include "zc/ffscript.h"
43 #include "particles.h"
44 #include "dialog/alert.h"
45 #include "base/misctypes.h"
46 #include "base/initdata.h"
47
48 extern sprite_list guys, items, Ewpns, Lwpns, chainlinks, decorations;
49 extern void setZScriptVersion(int32_t s_version);
50
51 static bool read_ext_zinfo = false, read_zinfo = false;
52 static bool loadquest_report = false;
53 static char const* loading_qst_name = NULL;
54 static std::string last_loaded_qstpath;
55 static byte loading_qst_num = 0;
56 static byte subscr_mode = ssdtMAX;
57 // Very old quests only used a byte for combos, and each screen had a "combo page" to vary
58 // what combos were used. This vector just lets us convert those old quests on load.
59 static std::vector<byte> old_combo_pages;
60
61 dword loading_tileset_flags = 0;
62
63 int32_t First[MAX_COMBO_COLS]={0},combo_alistpos[MAX_COMBO_COLS]={0},combo_pool_listpos[MAX_COMBO_COLS]={0},combo_auto_listpos[MAX_COMBO_COLS]={0};
64 map_and_screen map_page[MAX_MAPPAGE_BTNS]= {{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}};
65
66 #ifdef _MSC_VER
67 #define strncasecmp _strnicmp
68 #endif
69
70 #ifndef _AL_MALLOC
71 #define _AL_MALLOC(a) _al_malloc(a)
72 #define _AL_FREE(a) _al_free(a)
73 #endif
74
75 using std::string;
76 using std::pair;
77
78 extern int32_t hero_animation_speed; //lower is faster animation
79 extern byte *colordata;
80 extern tiledata *newtilebuf;
81 extern byte *trashbuf;
82 extern itemdata *itemsbuf;
83 extern wpndata *wpnsbuf;
84 extern comboclass *combo_class_buf;
85 extern guydata *guysbuf;
86 extern ZCHEATS zcheats;
87 extern char palnames[MAXLEVELS][17];
88 extern char *byte_conversion(int32_t number, int32_t format);
89 extern char *byte_conversion2(int32_t number1, int32_t number2, int32_t format1, int32_t format2);
90 string zScript;
91 424 std::map<int32_t, script_slot_data > ffcmap;
92 424 std::map<int32_t, script_slot_data > globalmap;
93 424 std::map<int32_t, script_slot_data > genericmap;
94 424 std::map<int32_t, script_slot_data > itemmap;
95 424 std::map<int32_t, script_slot_data > npcmap;
96 424 std::map<int32_t, script_slot_data > ewpnmap;
97 424 std::map<int32_t, script_slot_data > lwpnmap;
98 424 std::map<int32_t, script_slot_data > playermap;
99 424 std::map<int32_t, script_slot_data > dmapmap;
100 424 std::map<int32_t, script_slot_data > screenmap;
101 424 std::map<int32_t, script_slot_data > itemspritemap;
102 424 std::map<int32_t, script_slot_data > comboscriptmap;
103 424 std::map<int32_t, script_slot_data > subscreenmap;
104 void free_newtilebuf();
105 bool combosread=false;
106 bool mapsread=false;
107 bool fixffcs=false;
108 bool fixpolsvoice=false;
109
110 // Each section had a separate, secondary versioning number, but it was never really utilized for
111 // its intended purpose so it's been removed. But we still write something in this field.
112 232 bool write_deprecated_section_cversion(word section_version, PACKFILE* f)
113 {
114 232 return p_iputw(section_version, f);
115 }
116
117 14580 bool read_deprecated_section_cversion(PACKFILE* f)
118 {
119 word unused;
120 14580 return p_igetw(&unused, f);
121 }
122
123 21996 void script_slot_data::update()
124 {
125
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
✓ Branch 2 taken 21989 times.
21996 switch (format)
126 {
127 case SCRIPT_FORMAT_INVALID:
128 7 output = fmt::format("{} --{}", slotname, scriptname);
129 7 break;
130 21989 case SCRIPT_FORMAT_DEFAULT:
131 default:
132 21989 output = fmt::format("{} {}", slotname, scriptname);
133 21989 }
134 21996 }
135
136 char qstdat_string[2048] = { 0 };
137
138 static zinfo* load_tmp_zi = NULL;
139
140 int32_t memDBGwatch[8]= {0,0,0,0,0,0,0,0}; //So I can monitor memory crap
141 const byte clavio[9]={97,109,111,110,103,117,115,0};
142
143 //enum { qe_OK, qe_notfound, qe_invalid, qe_version, qe_obsolete,
144 // qe_missing, qe_internal, qe_pwd, qe_match, qe_minver };
145
146 const char *qst_error[] =
147 {
148 "OK","File not found","Invalid quest file",
149 "Version not supported","Obsolete version",
150 "Missing new data" , /* but let it pass in ZQuest */
151 "Internal error occurred", "Invalid password",
152 "Quest title doesn't match saved game", "Save file is for older version of quest; please start new save",
153 "Out of memory", "File Debug Mode", "Canceled", "", "No quest assigned"
154 };
155
156 //for legacy quests -DD
157 enum { ssiBOMB, ssiSWORD, ssiSHIELD, ssiCANDLE, ssiLETTER, ssiPOTION, ssiLETTERPOTION, ssiBOW, ssiARROW, ssiBOWANDARROW, ssiBAIT, ssiRING, ssiBRACELET, ssiMAP,
158 ssiCOMPASS, ssiBOSSKEY, ssiMAGICKEY, ssiBRANG, ssiWAND, ssiRAFT, ssiLADDER, ssiWHISTLE, ssiBOOK, ssiWALLET, ssiSBOMB, ssiHCPIECE, ssiAMULET, ssiFLIPPERS,
159 ssiHOOKSHOT, ssiLENS, ssiHAMMER, ssiBOOTS, ssiDIVINEFIRE, ssiDIVINEESCAPE, ssiDIVINEPROTECTION, ssiQUIVER, ssiBOMBBAG, ssiCBYRNA, ssiROCS, ssiHOVERBOOTS,
160 ssiSPINSCROLL, ssiCROSSSCROLL, ssiQUAKESCROLL, ssiWHISPRING, ssiCHARGERING, ssiPERILSCROLL, ssiWEALTHMEDAL, ssiHEARTRING, ssiMAGICRING, ssiSPINSCROLL2,
161 ssiQUAKESCROLL2, ssiAGONY, ssiSTOMPBOOTS, ssiWHIMSICALRING, ssiPERILRING, ssiMAX
162 };
163
164 static byte deprecated_rules[QUESTRULES_NEW_SIZE];
165
166
167 char *byte_conversion(int32_t number, int32_t format)
168 {
169 static char num_str[40];
170
171 if(format==-1) //auto
172 {
173 format=1; //bytes
174
175 if(number>1024)
176 {
177 format=2; //kilobytes
178 }
179
180 if(number>1024*1024)
181 {
182 format=3; //megabytes
183 }
184
185 if(number>1024*1024*1024)
186 {
187 format=4; //gigabytes (dude, what are you doing?)
188 }
189 }
190
191 switch(format)
192 {
193 case 1: //bytes
194 sprintf(num_str,"%db",number);
195 break;
196
197 case 2: //kilobytes
198 sprintf(num_str,"%.2fk",float(number)/1024);
199 break;
200
201 case 3: //megabytes
202 sprintf(num_str,"%.2fM",float(number)/(1024*1024));
203 break;
204
205 case 4: //gigabytes
206 sprintf(num_str,"%.2fG",float(number)/(1024*1024*1024));
207 break;
208
209 default:
210 abort();
211 break;
212 }
213
214 return num_str;
215 }
216
217 char *byte_conversion2(int32_t number1, int32_t number2, int32_t format1, int32_t format2)
218 {
219 static char num_str1[40];
220 static char num_str2[40];
221 static char num_str[80];
222
223 if(format1==-1) //auto
224 {
225 format1=1; //bytes
226
227 if(number1>1024)
228 {
229 format1=2; //kilobytes
230 }
231
232 if(number1>1024*1024)
233 {
234 format1=3; //megabytes
235 }
236
237 if(number1>1024*1024*1024)
238 {
239 format1=4; //gigabytes (dude, what are you doing?)
240 }
241 }
242
243 if(format2==-1) //auto
244 {
245 format2=1; //bytes
246
247 if(number2>1024)
248 {
249 format2=2; //kilobytes
250 }
251
252 if(number2>1024*1024)
253 {
254 format2=3; //megabytes
255 }
256
257 if(number2>1024*1024*1024)
258 {
259 format2=4; //gigabytes (dude, what are you doing?)
260 }
261 }
262
263 switch(format1)
264 {
265 case 1: //bytes
266 sprintf(num_str1,"%db",number1);
267 break;
268
269 case 2: //kilobytes
270 sprintf(num_str1,"%.2fk",float(number1)/1024);
271 break;
272
273 case 3: //megabytes
274 sprintf(num_str1,"%.2fM",float(number1)/(1024*1024));
275 break;
276
277 case 4: //gigabytes
278 sprintf(num_str1,"%.2fG",float(number1)/(1024*1024*1024));
279 break;
280
281 default:
282 abort();
283 break;
284 }
285
286 switch(format2)
287 {
288 case 1: //bytes
289 sprintf(num_str2,"%db",number2);
290 break;
291
292 case 2: //kilobytes
293 sprintf(num_str2,"%.2fk",float(number2)/1024);
294 break;
295
296 case 3: //megabytes
297 sprintf(num_str2,"%.2fM",float(number2)/(1024*1024));
298 break;
299
300 case 4: //gigabytes
301 sprintf(num_str2,"%.2fG",float(number2)/(1024*1024*1024));
302 break;
303
304 default:
305 abort();
306 break;
307 }
308
309 sprintf(num_str, "%s/%s", num_str1, num_str2);
310 return num_str;
311 }
312
313 char *ordinal(int32_t num)
314 {
315 static const char *ending[4] = {"st","nd","rd","th"};
316 static char ord_str[8];
317
318 char *end;
319 int32_t t=(num%100)/10;
320 int32_t n=num%10;
321
322 if(n>=1 && n<4 && t!=1)
323 end = (char *)ending[n-1];
324 else
325 end = (char *)ending[3];
326
327 sprintf(ord_str,"%d%s",num%10000,end);
328 return ord_str;
329 }
330
331 int32_t get_version_and_build(PACKFILE *f, word *version, word *build)
332 {
333 int32_t ret;
334 *version=0;
335 *build=0;
336 byte temp_map_count=map_count;
337 byte temp_midi_flags[MIDIFLAGS_SIZE];
338 memcpy(temp_midi_flags, midi_flags, MIDIFLAGS_SIZE);
339
340 zquestheader tempheader{};
341
342 if(!f)
343 {
344 return qe_invalid;
345 }
346
347 ret=readheader(f, &tempheader);
348
349 if(ret)
350 {
351 return ret;
352 }
353
354 map_count=temp_map_count;
355 memcpy(midi_flags, temp_midi_flags, MIDIFLAGS_SIZE);
356 *version=tempheader.zelda_version;
357 *build=tempheader.build;
358 return 0;
359 }
360
361
362 bool find_section(PACKFILE *f, int32_t section_id_requested)
363 {
364
365 if(!f)
366 {
367 return false;
368 }
369
370 int32_t section_id_read;
371 bool catchup=false;
372 word dummy;
373 byte tempbyte;
374 char tempbuf[65536];
375
376
377 switch(section_id_requested)
378 {
379 case ID_RULES:
380 case ID_STRINGS:
381 case ID_MISC:
382 case ID_TILES:
383 case ID_COMBOS:
384 case ID_CSETS:
385 case ID_MAPS:
386 case ID_DMAPS:
387 case ID_DOORS:
388 case ID_ITEMS:
389 case ID_WEAPONS:
390 case ID_COLORS:
391 case ID_ICONS:
392 case ID_INITDATA:
393 case ID_GUYS:
394 case ID_MIDIS:
395 case ID_CHEATS:
396 break;
397
398 default:
399 al_trace("Bad section requested!\n");
400 return false;
401 break;
402 }
403
404 dword section_size;
405
406 //section id
407 if(!p_mgetl(&section_id_read,f))
408 {
409 return false;
410 }
411
412 while(!pack_feof(f))
413 {
414 switch(section_id_read)
415 {
416 case ID_RULES:
417 case ID_STRINGS:
418 case ID_MISC:
419 case ID_TILES:
420 case ID_COMBOS:
421 case ID_CSETS:
422 case ID_MAPS:
423 case ID_DMAPS:
424 case ID_DOORS:
425 case ID_ITEMS:
426 case ID_WEAPONS:
427 case ID_COLORS:
428 case ID_ICONS:
429 case ID_INITDATA:
430 case ID_GUYS:
431 case ID_MIDIS:
432 case ID_CHEATS:
433 catchup=false;
434 break;
435
436 default:
437 break;
438 }
439
440
441 while(catchup)
442 {
443 //section id
444 section_id_read=(section_id_read<<8);
445
446 if(!p_getc(&tempbyte,f))
447 {
448 return false;
449 }
450
451 section_id_read+=tempbyte;
452 }
453
454 if(section_id_read==section_id_requested)
455 {
456 return true;
457 }
458 else
459 {
460 //section version info
461 if(!p_igetw(&dummy,f))
462 {
463 return false;
464 }
465
466 if(!p_igetw(&dummy,f))
467 {
468 return false;
469 }
470
471 //section size
472 if(!p_igetl(&section_size,f))
473 {
474 return false;
475 }
476
477 //pack_fseek(f, section_size);
478 while(section_size>65535)
479 {
480 pfread(tempbuf,65535,f);
481 tempbuf[65535]=0;
482 section_size-=65535;
483 }
484
485 if(section_size>0)
486 {
487 pfread(tempbuf,section_size,f);
488 tempbuf[section_size]=0;
489 }
490 }
491
492 //section id
493 if(!p_mgetl(&section_id_read,f))
494 {
495 return false;
496 }
497 }
498
499 return false;
500 }
501
502
503
504
505
506 bool valid_zqt(PACKFILE *f)
507 {
508
509 //word tiles_used;
510 //word combos_used;
511 //open the file
512 //PACKFILE *f = pack_fopen(path, F_READ_PACKED);
513 if(!f)
514 return false;
515
516 //for now, everything else is valid
517 return true;
518
519 /*int16_t version;
520 byte build;
521
522 //read the version and make sure it worked
523 if(!p_igetw(&version,f))
524 {
525 goto error;
526 }
527
528 //read the build and make sure it worked
529 if(!p_getc(&build,f))
530 goto error;
531
532 //read the tile info and make sure it worked
533 if(!p_igetw(&tiles_used,f))
534 {
535 goto error;
536 }
537
538 for (int32_t i=0; i<tiles_used; i++)
539 {
540 if(!pfread(trashbuf,tilesize(tf4Bit),f))
541 {
542 goto error;
543 }
544 }
545
546 //read the combo info and make sure it worked
547 if(!p_igetw(&combos_used,f))
548 {
549 goto error;
550 }
551 for (int32_t i=0; i<combos_used; i++)
552 {
553 if(!pfread(trashbuf,sizeof(newcombo),f))
554 {
555 goto error;
556 }
557 }
558
559 //read the palette info and make sure it worked
560 for (int32_t i=0; i<48; i++)
561 {
562 if(!pfread(trashbuf,newpdTOTAL,f))
563 {
564 goto error;
565 }
566 }
567 if(!pfread(trashbuf,sizeof(palcycle)*256*3,f))
568 {
569 goto error;
570 }
571 for (int32_t i=0; i<MAXLEVELS; i++)
572 {
573 if(!pfread(trashbuf,PALNAMESIZE,f))
574 {
575 goto error;
576 }
577 }
578
579 //read the sprite info and make sure it worked
580 for (int32_t i=0; i<MAXITEMS; i++)
581 {
582 if(!pfread(trashbuf,sizeof(itemdata),f))
583 {
584 goto error;
585 }
586 }
587
588 for (int32_t i=0; i<MAXWPNS; i++)
589 {
590 if(!pfread(trashbuf,sizeof(wpndata),f))
591 {
592 goto error;
593 }
594 }
595
596 //read the triforce pieces info and make sure it worked
597 for (int32_t i=0; i<8; ++i)
598 {
599 if(!p_getc(&trashbuf,f))
600 {
601 goto error;
602 }
603 }
604
605
606
607 //read the game icons info and make sure it worked
608 for (int32_t i=0; i<4; ++i)
609 {
610 if(!p_igetw(&trashbuf,f))
611 {
612 goto error;
613 }
614 }
615
616 //read the misc colors info and map styles info and make sure it worked
617 if(!pfread(trashbuf,sizeof(zcolors),f))
618 {
619 goto error;
620 }
621
622 //read the template screens and make sure it worked
623 byte num_maps;
624 if(!p_getc(&num_maps,f))
625 {
626 goto error;
627 }
628 for (int32_t i=0; i<TEMPLATES; i++)
629 {
630 if(!pfread(trashbuf,sizeof(mapscr),f))
631 {
632 goto error;
633 }
634 }
635 if (num_maps>1) //dungeon templates
636 {
637 for (int32_t i=0; i<TEMPLATES; i++)
638 {
639 if(!pfread(trashbuf,sizeof(mapscr),f))
640 {
641 goto error;
642 }
643 }
644 }
645
646 //yay! it worked! close the file and say everything was ok.
647 pack_fclose(f);
648 return true;
649
650 error:
651 pack_fclose(f);
652 return false;*/
653 }
654
655 bool valid_zqt(const char *filename)
656 {
657 PACKFILE *f=NULL;
658 bool isvalid;
659 int32_t error;
660 f=open_quest_file(&error, filename, false);
661
662 if(!f)
663 {
664 // setPackfilePassword(NULL);
665 return false;
666 }
667
668 isvalid=valid_zqt(f);
669
670 clear_quest_tmpfile();
671 pack_fclose(f);
672
673 // setPackfilePassword(NULL);
674 return isvalid;
675 }
676
677 /*
678 .qst file history
679
680 .qst files have always been compressed using allegro's packfiles.
681
682 At some point, an encoding layer was added. The two layers look like this:
683
684 1) The top layer is from us. See decode_file_007.
685 [0-24] Preamble "Zelda Classic Quest File"
686 [25-28] Initial decoding seed value.
687 [29-X] Allegro-compressed payload (AKA "packed" file), but XOR'd based on seed value
688 [last 4] Checksum
689
690 2) The bottom layer is a "compressed packed file" from Allegro 4. The entire payload
691 is XOR'd with a password (datapwd). Once that is undone, the first four bytes are "slh!",
692 followed by a lzss compressed representation of the payload (from allergo' packfile compression).
693 The oldest quests skip the password part.
694
695 Simply, the job of this function is to peel away the top layer.
696
697 With this second layer of encryption, the data isn't any more secure, and adds a significant delay
698 in opening and saving files. There is no version field, so they decryption key is
699 found via trial-by-error (very slow!)
700
701 There are other file types of interest:
702 - .zqt: quest template files, skips top-layer encryption pass
703 - .qsu: "unencoded" (and uncompressed) files; skips encryption and compression (also makes the longtan password moot)
704 - .qu?: same as above. automated backup files
705 - .qb?: same as above. automated backup files
706 - .qt?: compressed and encrypted (or not encrypted, as of May 2023)
707
708 May 2023: .qst files are now saved without the top layer encoding, and no allegro packfile password. The first bytes of these
709 files are now "slh!.AG ZC Enhanced Quest File".
710 The following command will take an existing qst file and upgrade it: `./zquest -unencrypt-qst <input> <output>`
711 */
712 804 PACKFILE *open_quest_file(int32_t *open_error, const char *filename, bool show_progress)
713 {
714
1/2
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
804 if (show_progress)
715 {
716 box_start(1, "Loading Quest", get_zc_font(font_lfont), font, true);
717 }
718
719 804 auto unencrypted_result = try_open_maybe_legacy_encoded_file(filename, ENC_STR, nullptr, QH_NEWIDSTR, QH_IDSTR);
720
2/2
✓ Branch 0 taken 316 times.
✓ Branch 1 taken 488 times.
804 if (unencrypted_result.decoded_pf)
721 316 return unencrypted_result.decoded_pf;
722
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 488 times.
488 if (unencrypted_result.not_found)
723 {
724 *open_error = qe_notfound;
725 return nullptr;
726 }
727
728 // Everything below here is legacy code - recently saved quest files will have
729 // returned by now.
730 // The only replay qst file that is still using this legacy encoding is `link_to_the_zelda.qst`.
731
732 // Note: although this is primarily for loading .qst files, it can also handle all of the
733 // file types mentioned in the comment above. No need to be told if the file being loaded
734 // is encrypted or compressed, we can do some simple and fast checks to determine how to load it.
735 488 bool top_layer_compressed = unencrypted_result.top_layer_compressed;
736 488 bool compressed = unencrypted_result.compressed;
737 488 bool encrypted = unencrypted_result.encrypted;
738
739 char tmpfilename[L_tmpnam];
740 488 temp_name(tmpfilename);
741 char percent_done[30];
742 488 int32_t current_method=0;
743
744 PACKFILE *f;
745 488 const char *passwd= encrypted ? datapwd : "";
746
747 // oldquest flag is set when an unencrypted qst file is suspected.
748 488 bool oldquest = false;
749 int32_t ret;
750
751
1/2
✓ Branch 0 taken 488 times.
✗ Branch 1 not taken.
488 if(strcmp(filename, "default.qst")!=0)
752 {
753 488 box_out(filename);
754 488 }
755 else
756 {
757 box_out("new quest"); // Or whatever
758 }
759 488 box_out("...");
760 488 box_eol();
761 488 box_eol();
762
763
1/2
✓ Branch 0 taken 488 times.
✗ Branch 1 not taken.
488 if(encrypted)
764 {
765 488 box_out("Decrypting...");
766 488 box_save_x();
767 488 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_MAX-1, top_layer_compressed, passwd);
768
769
2/2
✓ Branch 0 taken 425 times.
✓ Branch 1 taken 63 times.
488 if(ret)
770 {
771
1/3
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
63 switch(ret)
772 {
773 case 1:
774 box_out("error.");
775 box_eol();
776 box_end(true);
777 *open_error=qe_notfound;
778 return NULL;
779
780 case 2:
781 box_out("error.");
782 box_eol();
783 box_end(true);
784 *open_error=qe_internal;
785 return NULL;
786 // be sure not to delete tmpfilename now...
787 }
788
789
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(ret==5) //old encryption?
790 {
791 63 current_method++;
792 63 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
793 63 box_out(percent_done);
794 63 box_load_x();
795 63 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_211B9, strstr(filename, ".dat#")!=NULL, passwd);
796 63 }
797
798
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(ret==5) //old encryption?
799 {
800 63 current_method++;
801 63 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
802 63 box_out(percent_done);
803 63 box_load_x();
804 63 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B185, strstr(filename, ".dat#")!=NULL, passwd);
805 63 }
806
807
2/2
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 18 times.
63 if(ret==5) //old encryption?
808 {
809 18 current_method++;
810 18 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
811 18 box_out(percent_done);
812 18 box_load_x();
813 18 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B105, strstr(filename, ".dat#")!=NULL, passwd);
814 18 }
815
816
2/2
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 12 times.
63 if(ret==5) //old encryption?
817 {
818 12 current_method++;
819 12 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
820 12 box_out(percent_done);
821 12 box_load_x();
822 12 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B104, strstr(filename, ".dat#")!=NULL, passwd);
823 12 }
824
825
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(ret)
826 {
827 oldquest = true;
828 passwd="";
829 }
830 63 }
831
832 488 box_out("okay.");
833 488 box_eol();
834 488 }
835 else
836 {
837 oldquest = true;
838 }
839
840 488 box_out("Opening...");
841
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 488 times.
488 f = pack_fopen_password(oldquest ? filename : tmpfilename, compressed ? F_READ_PACKED : F_READ, passwd);
842
1/2
✓ Branch 0 taken 488 times.
✗ Branch 1 not taken.
488 if(!f)
843 {
844 if((compressed==1)&&(errno==EDOM))
845 {
846 f = pack_fopen_password(oldquest ? filename : tmpfilename, F_READ, passwd);
847 }
848
849 if(!f)
850 {
851 if(!oldquest)
852 {
853 delete_file(tmpfilename);
854 }
855 box_out("error.");
856 box_eol();
857 box_end(true);
858 *open_error=qe_invalid;
859 return NULL;
860 }
861 }
862
863
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 488 times.
488 if(!oldquest)
864 {
865 488 delete_file(tmpfilename);
866 488 }
867
868 488 box_out("okay.");
869 488 box_eol();
870
871 488 return f;
872 804 }
873
874 PACKFILE *open_quest_template(zquestheader *Header, const char *filename, bool validate)
875 {
876 PACKFILE *f=NULL;
877 int32_t open_error=0;
878
879 if (Header->templatepath[0] != 0)
880 {
881 // TODO: should be safe to remove this, no one seems to use custom quest templates.
882 filename=Header->templatepath;
883 }
884
885 f=open_quest_file(&open_error, filename, false);
886
887 if(!f)
888 {
889 return NULL;
890 }
891
892 if(validate)
893 {
894 if(!valid_zqt(f))
895 {
896 jwin_alert("Error","Invalid Quest Template",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
897 pack_fclose(f);
898 clear_quest_tmpfile();
899 return NULL;
900 }
901 }
902
903 return f;
904 }
905
906 static bool init_section(zquestheader *Header, int32_t section_id, miscQdata *Misc, zctune *tunes, bool validate, const char* filename)
907 {
908 // The only time the player uses this is to init tiles for some quests 1.90 or older. See readtiles.
909 if (get_app_id() == App::zelda)
910 assert(section_id == ID_TILES);
911
912 combosread=false;
913 mapsread=false;
914 fixffcs=false;
915
916 switch(section_id)
917 {
918 case ID_RULES:
919 case ID_STRINGS:
920 case ID_MISC:
921 case ID_TILES:
922 case ID_COMBOS:
923 case ID_CSETS:
924 case ID_MAPS:
925 case ID_DMAPS:
926 case ID_DOORS:
927 case ID_ITEMS:
928 case ID_WEAPONS:
929 case ID_COLORS:
930 case ID_ICONS:
931 case ID_INITDATA:
932 case ID_GUYS:
933 case ID_MIDIS:
934 case ID_CHEATS:
935 case ID_ITEMDROPSETS:
936 case ID_FAVORITES:
937 break;
938
939 default:
940 return false;
941 break;
942 }
943
944 int32_t ret;
945 word version, build;
946 PACKFILE *f=NULL;
947
948 //why is this here?
949 /*
950 if(colordata==NULL)
951 return false;
952 */
953
954 //setPackfilePassword(datapwd);
955 f=open_quest_template(Header, filename, validate);
956
957 if(!f) //no file, nothing to delete
958 {
959 // setPackfilePassword(NULL);
960 return false;
961 }
962
963 ret=get_version_and_build(f, &version, &build);
964
965 if(ret||(version==0))
966 {
967 pack_fclose(f);
968 clear_quest_tmpfile();
969
970 // setPackfilePassword(NULL);
971 return false;
972 }
973
974 if(!find_section(f, section_id))
975 {
976 al_trace("Can't find section!\n");
977 pack_fclose(f);
978 clear_quest_tmpfile();
979
980 //setPackfilePassword(NULL);
981 return false;
982 }
983
984 switch(section_id)
985 {
986 case ID_RULES:
987 //rules
988 ret=readrules(f, Header);
989 break;
990
991 case ID_STRINGS:
992 //strings
993 ret=readstrings(f, Header);
994 break;
995
996 case ID_MISC:
997 //misc data
998 ret=readmisc(f, Header, Misc);
999 break;
1000
1001 case ID_TILES:
1002 //tiles
1003 ret=readtiles(f, newtilebuf, Header, version, build, 0, NEWMAXTILES, true);
1004 break;
1005
1006 case ID_COMBOS:
1007 //combos
1008 clear_combos();
1009 ret=readcombos(f, Header, version, build, 0, MAXCOMBOS);
1010 combosread=true;
1011 break;
1012
1013 case ID_COMBOALIASES:
1014 //combos
1015 ret=readcomboaliases(f, Header, version, build);
1016 break;
1017
1018 case ID_CSETS:
1019 //color data
1020 ret=readcolordata(f, Misc, version, build, 0, newerpdTOTAL);
1021 break;
1022
1023 case ID_MAPS:
1024 //maps
1025 ret=readmaps(f, Header);
1026 mapsread=true;
1027 break;
1028
1029 case ID_DMAPS:
1030 //dmaps
1031 ret=readdmaps(f, Header, version, build, 0, MAXDMAPS);
1032 break;
1033
1034 case ID_DOORS:
1035 //door combo sets
1036 ret=readdoorcombosets(f, Header);
1037 break;
1038
1039 case ID_ITEMS:
1040 //items
1041 ret=readitems(f, version, build);
1042 break;
1043
1044 case ID_WEAPONS:
1045 //weapons
1046 ret=readweapons(f, Header);
1047 break;
1048
1049 case ID_COLORS:
1050 //misc. colors
1051 ret=readmisccolors(f, Header, Misc);
1052 break;
1053
1054 case ID_ICONS:
1055 //game icons
1056 ret=readgameicons(f, Header, Misc);
1057 break;
1058
1059 case ID_INITDATA:
1060 //initialization data
1061 ret=readinitdata(f, Header);
1062 break;
1063
1064 case ID_GUYS:
1065 //guys
1066 ret=readguys(f, Header);
1067 break;
1068
1069 case ID_MIDIS:
1070 //midis
1071 ret=readtunes(f, Header, tunes);
1072 break;
1073
1074 case ID_CHEATS:
1075 //cheat codes
1076 ret=readcheatcodes(f, Header);
1077 break;
1078
1079 case ID_ITEMDROPSETS:
1080 //item drop sets
1081 // Why is this one commented out?
1082 //ret=readitemdropsets(f, (int32_t)version, (word)build);
1083 break;
1084
1085 case ID_FAVORITES:
1086 // favorite combos and aliases
1087 ret=readfavorites(f, version);
1088 break;
1089
1090 default:
1091 ret=-1;
1092 break;
1093 }
1094
1095 pack_fclose(f);
1096 clear_quest_tmpfile();
1097
1098 //setPackfilePassword(NULL);
1099 if(!ret)
1100 {
1101 return true;
1102 }
1103
1104 return false;
1105 }
1106
1107 bool init_tiles_for_190(bool validate, zquestheader *Header)
1108 {
1109 return init_section(Header, ID_TILES, NULL, NULL, validate, "assets/190_tiles.qst");
1110 }
1111
1112 bool init_tiles(bool validate, zquestheader *Header)
1113 {
1114 return init_section(Header, ID_TILES, NULL, NULL, validate, "modules/classic/default.qst");
1115 }
1116
1117 bool init_combos(bool validate, zquestheader *Header)
1118 {
1119 return init_section(Header, ID_COMBOS, NULL, NULL, validate, "modules/classic/default.qst");
1120 }
1121
1122 bool init_colordata(bool validate, zquestheader *Header, miscQdata *Misc)
1123 {
1124 return init_section(Header, ID_CSETS, Misc, NULL, validate, "modules/classic/default.qst");
1125 }
1126
1127 804 void init_spritelists()
1128 {
1129
2/2
✓ Branch 0 taken 612 times.
✓ Branch 1 taken 192 times.
804 if(FFCore.quest_format[vZelda] < 0x255)
1130 {
1131 612 guys.setMax(255);
1132 612 items.setMax(255);
1133 612 Ewpns.setMax(255);
1134 612 Lwpns.setMax(255);
1135 612 chainlinks.setMax(255);
1136 612 decorations.setMax(255);
1137 612 particles.setMax(255);
1138 612 }
1139 else
1140 {
1141 192 guys.setMax(255);
1142 192 items.setMax(255);
1143 192 Ewpns.setMax(255);
1144 192 Lwpns.setMax(255);
1145 192 chainlinks.setMax(255);
1146 192 decorations.setMax(255);
1147 192 particles.setMax(255*((255*4)+1)); //255 per sprite that can use particles; guys, items, ewpns, lwpns, +HERO
1148 }
1149 804 }
1150
1151 315 bool reset_items(bool validate, zquestheader *Header)
1152 {
1153 315 bool ret = true;
1154
1/2
✓ Branch 0 taken 315 times.
✗ Branch 1 not taken.
315 if (get_app_id() == App::zquest)
1155 ret = init_section(Header, ID_ITEMS, NULL, NULL, validate, "modules/classic/default.qst");
1156
1157
2/2
✓ Branch 0 taken 315 times.
✓ Branch 1 taken 80640 times.
80955 for(int32_t i=0; i<MAXITEMS; i++) reset_itemname(i);
1158
1159 315 return ret;
1160 }
1161
1162 bool reset_guys()
1163 {
1164 // The .dat file's guys definitions are always synchronised with defdata.cpp's - even the tile settings.
1165 init_guys(V_GUYS);
1166 return true;
1167 }
1168
1169 bool reset_wpns(bool validate, zquestheader *Header)
1170 {
1171 bool ret = true;
1172 if (get_app_id() == App::zquest)
1173 ret = init_section(Header, ID_WEAPONS, NULL, NULL, validate, "modules/classic/default.qst");
1174
1175 for(int32_t i=0; i<MAXWPNS; i++)
1176 reset_weaponname(i);
1177
1178 return ret;
1179 }
1180
1181 bool reset_mapstyles(bool validate, miscQdata *Misc)
1182 {
1183 Misc->colors.blueframe_tile = 20044;
1184 Misc->colors.blueframe_cset = 0;
1185 Misc->colors.triforce_tile = 23461;
1186 Misc->colors.triforce_cset = 1;
1187 Misc->colors.triframe_tile = 18752;
1188 Misc->colors.triframe_cset = 1;
1189 Misc->colors.overworld_map_tile = 16990;
1190 Misc->colors.overworld_map_cset = 2;
1191 Misc->colors.HCpieces_tile = 21160;
1192 Misc->colors.HCpieces_cset = 8;
1193 Misc->colors.dungeon_map_tile = 19651;
1194 Misc->colors.dungeon_map_cset = 8;
1195 return true;
1196 }
1197
1198 899316 int32_t read_weap_data(weapon_data& data, PACKFILE* f)
1199 {
1200 word v_weapon_data;
1201
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 899316 times.
899316 if(!p_igetw(&v_weapon_data,f))
1202 return qe_invalid;
1203
1204
1/2
✓ Branch 0 taken 899316 times.
✗ Branch 1 not taken.
899316 if (!p_igetw(&(data.flags), f))
1205 return qe_invalid;
1206
1207
1/2
✓ Branch 0 taken 899316 times.
✗ Branch 1 not taken.
899316 if (!p_igetl(&(data.moveflags), f))
1208 return qe_invalid;
1209
1210
1/2
✓ Branch 0 taken 899316 times.
✗ Branch 1 not taken.
899316 if (!p_igetw(&(data.wflags), f))
1211 return qe_invalid;
1212
1213
2/2
✓ Branch 0 taken 4496580 times.
✓ Branch 1 taken 899316 times.
5395896 for (int32_t q = 0; q < WPNSPR_MAX; ++q)
1214 {
1215
1/2
✓ Branch 0 taken 4496580 times.
✗ Branch 1 not taken.
4496580 if (!p_getc(&(data.burnsprs[q]), f))
1216 return qe_invalid;
1217
1/2
✓ Branch 0 taken 4496580 times.
✗ Branch 1 not taken.
4496580 if (!p_getc(&(data.light_rads[q]), f))
1218 return qe_invalid;
1219 4496580 }
1220
1/2
✓ Branch 0 taken 899316 times.
✗ Branch 1 not taken.
899316 if (!p_getc(&(data.glow_shape), f))
1221 return qe_invalid;
1222
1223
1/2
✓ Branch 0 taken 899316 times.
✗ Branch 1 not taken.
899316 if (!p_igetl(&(data.override_flags), f))
1224 return qe_invalid;
1225
1/2
✓ Branch 0 taken 899316 times.
✗ Branch 1 not taken.
899316 if (!p_igetl(&(data.tilew), f))
1226 return qe_invalid;
1227
1/2
✓ Branch 0 taken 899316 times.
✗ Branch 1 not taken.
899316 if (!p_igetl(&(data.tileh), f))
1228 return qe_invalid;
1229
1/2
✓ Branch 0 taken 899316 times.
✗ Branch 1 not taken.
899316 if (!p_igetl(&(data.hxsz), f))
1230 return qe_invalid;
1231
1/2
✓ Branch 0 taken 899316 times.
✗ Branch 1 not taken.
899316 if (!p_igetl(&(data.hysz), f))
1232 return qe_invalid;
1233
1/2
✓ Branch 0 taken 899316 times.
✗ Branch 1 not taken.
899316 if (!p_igetl(&(data.hzsz), f))
1234 return qe_invalid;
1235
1/2
✓ Branch 0 taken 899316 times.
✗ Branch 1 not taken.
899316 if (!p_igetl(&(data.hxofs), f))
1236 return qe_invalid;
1237
1/2
✓ Branch 0 taken 899316 times.
✗ Branch 1 not taken.
899316 if (!p_igetl(&(data.hyofs), f))
1238 return qe_invalid;
1239
1/2
✓ Branch 0 taken 899316 times.
✗ Branch 1 not taken.
899316 if (!p_igetl(&(data.xofs), f))
1240 return qe_invalid;
1241
1/2
✓ Branch 0 taken 899316 times.
✗ Branch 1 not taken.
899316 if (!p_igetl(&(data.yofs), f))
1242 return qe_invalid;
1243
1244
1/2
✓ Branch 0 taken 899316 times.
✗ Branch 1 not taken.
899316 if (!p_igetzf(&(data.step), f))
1245 return qe_invalid;
1246
1247
1/2
✓ Branch 0 taken 899316 times.
✗ Branch 1 not taken.
899316 if (!p_getc(&(data.unblockable), f))
1248 return qe_invalid;
1249
1250
1/2
✓ Branch 0 taken 899316 times.
✗ Branch 1 not taken.
899316 if (!p_igetl(&(data.timeout), f))
1251 return qe_invalid;
1252
1253
1/2
✓ Branch 0 taken 899316 times.
✗ Branch 1 not taken.
899316 if (!p_getc(&(data.imitate_weapon), f))
1254 return qe_invalid;
1255
1/2
✓ Branch 0 taken 899316 times.
✗ Branch 1 not taken.
899316 if (!p_getc(&(data.default_defense), f))
1256 return qe_invalid;
1257
1258
1/2
✓ Branch 0 taken 899316 times.
✗ Branch 1 not taken.
899316 if (!p_getc(&(data.lift_level), f))
1259 return qe_invalid;
1260
1/2
✓ Branch 0 taken 899316 times.
✗ Branch 1 not taken.
899316 if (!p_getc(&(data.lift_time), f))
1261 return qe_invalid;
1262
1/2
✓ Branch 0 taken 899316 times.
✗ Branch 1 not taken.
899316 if (!p_igetzf(&(data.lift_height), f))
1263 return qe_invalid;
1264
1265
1/2
✓ Branch 0 taken 899316 times.
✗ Branch 1 not taken.
899316 if(!p_igetw(&(data.script), f))
1266 return qe_invalid;
1267
2/2
✓ Branch 0 taken 7194528 times.
✓ Branch 1 taken 899316 times.
8093844 for(uint q = 0; q < 8; ++q)
1268
1/2
✓ Branch 0 taken 7194528 times.
✗ Branch 1 not taken.
7194528 if(!p_igetl(&(data.initd[q]), f))
1269 return qe_invalid;
1270
1/2
✓ Branch 0 taken 899316 times.
✗ Branch 1 not taken.
899316 if(!p_igetw(&(data.pierce_count), f))
1271 return qe_invalid;
1272 899316 return 0;
1273 899316 }
1274
1275 373 int32_t get_qst_buffers()
1276 {
1277 373 TheMaps.resize(MAPSCRS);
1278 373 old_combo_pages.resize(MAPSCRS);
1279 373 map_autolayers.resize(6);
1280
1281 373 Z_message("OK\n");
1282
1283 // The vast majority of finished quests (and I presume this will be consistent for all time) use < 1000 strings in total.
1284 // (Shoelace's "Hero of Dreams" uses 1415.)
1285 // So let's be a bit generous and allow 4096 initially.
1286 // In the rare event that a quest overshoots this mark, we'll reallocate to the full 65535 later.
1287 // I tested it and it worked without flaw on 6/6/11. - L.
1288 // 2022: bumped from 4096 to 8192 to avoid a bug where the Strings menu shows (None) strings when the list passes
1289 // this threshold. Possibly some bug related to `msglistcache` to being reset?
1290 // See https://discord.com/channels/876899628556091432/992984989073416242
1291 373 msg_strings_size = 8192;
1292
1293
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 373 times.
373 MsgStrings = new MsgStr[msg_strings_size];
1294
1295 //memset(MsgStrings, 0, sizeof(MsgStr)*msg_strings_size);
1296
2/2
✓ Branch 0 taken 3055616 times.
✓ Branch 1 taken 373 times.
3055989 for(auto q = 0; q < msg_strings_size; ++q)
1297 {
1298 3055616 MsgStrings[q].clear();
1299 3055616 }
1300
1301
1/2
✓ Branch 0 taken 373 times.
✗ Branch 1 not taken.
373 if((DMaps=new dmap[MAXDMAPS])==NULL)
1302 return 0;
1303
1304
1305
1306 373 combobuf.clear();
1307 373 combobuf.resize(MAXCOMBOS);
1308
1309
1310
1/2
✓ Branch 0 taken 373 times.
✗ Branch 1 not taken.
373 if((colordata=(byte*)malloc(psTOTAL255))==NULL)
1311 return 0;
1312
1313 373 free_newtilebuf();
1314
1/2
✓ Branch 0 taken 373 times.
✗ Branch 1 not taken.
373 if((newtilebuf=(tiledata*)malloc(NEWMAXTILES*sizeof(tiledata)))==NULL)
1315 return 0;
1316
1317 373 memset(newtilebuf, 0, NEWMAXTILES*sizeof(tiledata));
1318 //Z_message("Performed memset on tiles\n");
1319 373 clear_tiles(newtilebuf);
1320 //Z_message("Performed clear_tiles()\n");
1321
1322
2/2
✓ Branch 0 taken 360 times.
✓ Branch 1 taken 13 times.
373 if (get_app_id() == App::zquest)
1323 {
1324
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if((grabtilebuf=(tiledata*)malloc(NEWMAXTILES*sizeof(tiledata)))==NULL)
1325 return 0;
1326
1327 13 memset(grabtilebuf, 0, NEWMAXTILES*sizeof(tiledata));
1328 13 clear_tiles(grabtilebuf);
1329 13 }
1330
1331
1/2
✓ Branch 0 taken 373 times.
✗ Branch 1 not taken.
373 if((trashbuf=(byte*)malloc(100000))==NULL)
1332 return 0;
1333
1334 // Big, ugly band-aid here. Perhaps the most common cause of random crashes
1335 // has been inadvertently accessing itemsbuf[-1]. All such crashes should be
1336 // fixed by ensuring there's actually itemdata there.
1337 // If you change this, be sure to update del_qst_buffers, too.
1338
1339
1/2
✓ Branch 0 taken 373 times.
✗ Branch 1 not taken.
373 if((itemsbuf=(itemdata*)malloc(sizeof(itemdata)*(MAXITEMS+1)))==NULL)
1340 return 0;
1341
1342
2/2
✓ Branch 0 taken 95861 times.
✓ Branch 1 taken 373 times.
96234 for(size_t q = 0; q < MAXITEMS+1; ++q)
1343 95861 itemsbuf[q].clear();
1344 373 itemsbuf++;
1345
1346
1/2
✓ Branch 0 taken 373 times.
✗ Branch 1 not taken.
373 if((wpnsbuf=(wpndata*)malloc(sizeof(wpndata)*MAXWPNS))==NULL)
1347 return 0;
1348
1349 373 memset(wpnsbuf,0,sizeof(wpndata)*MAXWPNS);
1350
1351
1/2
✓ Branch 0 taken 373 times.
✗ Branch 1 not taken.
373 if((guysbuf=(guydata*)malloc(sizeof(guydata)*MAXGUYS))==NULL)
1352 return 0;
1353
1354
2/2
✓ Branch 0 taken 190976 times.
✓ Branch 1 taken 373 times.
191349 for(size_t q = 0; q < MAXGUYS; ++q)
1355 190976 guysbuf[q].clear();
1356
1357
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 373 times.
373 if((combo_class_buf=(comboclass*)malloc(sizeof(comboclass)*cMAX))==NULL)
1358 return 0;
1359
1360 373 return 1;
1361 373 }
1362
1363
1364 699 void free_newtilebuf()
1365 {
1366
2/2
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 372 times.
699 if(newtilebuf)
1367 {
1368
2/2
✓ Branch 0 taken 70141500 times.
✓ Branch 1 taken 327 times.
70141827 for(int32_t i=0; i<NEWMAXTILES; i++)
1369
2/2
✓ Branch 0 taken 214500 times.
✓ Branch 1 taken 69927000 times.
140068500 if(newtilebuf[i].data)
1370 69927000 free(newtilebuf[i].data);
1371
1372 327 free(newtilebuf);
1373 327 newtilebuf = 0;
1374 327 }
1375 699 }
1376
1377 326 void free_grabtilebuf()
1378 {
1379
2/2
✓ Branch 0 taken 315 times.
✓ Branch 1 taken 11 times.
326 if (get_app_id() == App::zquest)
1380 {
1381
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(grabtilebuf)
1382 {
1383
2/2
✓ Branch 0 taken 2359500 times.
✓ Branch 1 taken 11 times.
2359511 for(int32_t i=0; i<NEWMAXTILES; i++)
1384
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2359500 times.
2359500 if(grabtilebuf[i].data) free(grabtilebuf[i].data);
1385
1386 11 free(grabtilebuf);
1387 11 grabtilebuf = 0;
1388 11 }
1389 11 }
1390 326 }
1391
1392 326 void del_qst_buffers()
1393 {
1394
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 326 times.
✓ Branch 2 taken 326 times.
✗ Branch 3 not taken.
326 if(MsgStrings) delete[] MsgStrings;
1395
1396
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 326 times.
✓ Branch 2 taken 326 times.
✗ Branch 3 not taken.
326 if (DMaps) delete[] DMaps;
1397
1398 326 combobuf.clear();
1399
1400
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 326 times.
326 if(colordata) free(colordata);
1401
1402 326 free_newtilebuf();
1403 326 free_grabtilebuf();
1404
1405
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 326 times.
326 if(trashbuf) free(trashbuf);
1406
1407 // See get_qst_buffers
1408
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 326 times.
326 if(itemsbuf)
1409 {
1410 326 itemsbuf--;
1411 326 free(itemsbuf);
1412 326 }
1413
1414
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 326 times.
326 if(wpnsbuf) free(wpnsbuf);
1415
1416
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 326 times.
326 if(guysbuf) free(guysbuf);
1417
1418
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 326 times.
326 if(combo_class_buf) free(combo_class_buf);
1419 326 }
1420
1421 18 bool init_palnames()
1422 {
1423 // if(palnames==NULL)
1424 // return false;
1425
1426
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 18 times.
9234 for(int32_t x=0; x<MAXLEVELS; x++)
1427 {
1428
4/4
✓ Branch 0 taken 9162 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 18 times.
9216 switch(x)
1429 {
1430 case 0:
1431 18 sprintf(palnames[x],"Overworld");
1432 18 break;
1433
1434 case 10:
1435 18 sprintf(palnames[x],"Caves");
1436 18 break;
1437
1438 case 11:
1439 18 sprintf(palnames[x],"Passageways");
1440 18 break;
1441
1442 default:
1443 9162 sprintf(palnames[x],"%c",0);
1444 9162 break;
1445 }
1446 9216 }
1447
1448 18 return true;
1449 }
1450
1451 100192 static void *read_block(PACKFILE *f, int32_t size, int32_t alloc_size)
1452 {
1453 void *p;
1454
1455
1/2
✓ Branch 0 taken 100192 times.
✗ Branch 1 not taken.
100192 p = _AL_MALLOC(MAX(size, alloc_size));
1456
1457
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100192 times.
100192 if(!p)
1458 {
1459 return NULL;
1460 }
1461
1462
1/2
✓ Branch 0 taken 100192 times.
✗ Branch 1 not taken.
100192 if(!pfread(p,size,f))
1463 {
1464 _AL_FREE(p);
1465 return NULL;
1466 }
1467
1468
1/2
✓ Branch 0 taken 100192 times.
✗ Branch 1 not taken.
100192 if(pack_ferror(f))
1469 {
1470 _AL_FREE(p);
1471 return NULL;
1472 }
1473
1474 100192 return p;
1475 100192 }
1476
1477 // Only use for reading parts of older quests (Header->zelda_version <= 0x192)
1478 static const byte* legacy_skip_flags;
1479
1480 /* read_midi:
1481 * Reads MIDI data from a datafile (this is not the same thing as the
1482 * standard midi file format).
1483 */
1484
1485 10262 static MIDI *read_midi(PACKFILE *f)
1486 {
1487 MIDI *m;
1488 int32_t c;
1489 10262 int16_t divisions=0;
1490 10262 int32_t len=0;
1491
1492 10262 m = (MIDI*)_AL_MALLOC(sizeof(MIDI));
1493
1494
1/2
✓ Branch 0 taken 10262 times.
✗ Branch 1 not taken.
10262 if(!m)
1495 {
1496 return NULL;
1497 }
1498
1499
2/2
✓ Branch 0 taken 328384 times.
✓ Branch 1 taken 10262 times.
338646 for(c=0; c<MIDI_TRACKS; c++)
1500 {
1501 328384 m->track[c].len = 0;
1502 328384 m->track[c].data = NULL;
1503 328384 }
1504
1505 10262 p_mgetw(&divisions,f);
1506 10262 m->divisions=divisions;
1507
1508
2/2
✓ Branch 0 taken 328384 times.
✓ Branch 1 taken 10262 times.
338646 for(c=0; c<MIDI_TRACKS; c++)
1509 {
1510 328384 p_mgetl(&len,f);
1511 328384 m->track[c].len=len;
1512
1513
2/2
✓ Branch 0 taken 228192 times.
✓ Branch 1 taken 100192 times.
328384 if(m->track[c].len > 0)
1514 {
1515 100192 m->track[c].data = (byte*)read_block(f, m->track[c].len, 0);
1516
1517
1/2
✓ Branch 0 taken 100192 times.
✗ Branch 1 not taken.
100192 if(!m->track[c].data)
1518 {
1519 destroy_midi(m);
1520 return NULL;
1521 }
1522 100192 }
1523 328384 }
1524
1525 LOCK_DATA(m, sizeof(MIDI));
1526
1527
2/2
✓ Branch 0 taken 328384 times.
✓ Branch 1 taken 10262 times.
338646 for(c=0; c<MIDI_TRACKS; c++)
1528 {
1529
2/2
✓ Branch 0 taken 100192 times.
✓ Branch 1 taken 228192 times.
328384 if(m->track[c].data)
1530 {
1531 LOCK_DATA(m->track[c].data, m->track[c].len);
1532 100192 }
1533 328384 }
1534
1535 10262 return m;
1536 10262 }
1537
1538 void clear_combo(int32_t i)
1539 {
1540 combobuf[i].clear();
1541 }
1542
1543 void clear_combos()
1544 {
1545 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
1546 clear_combo(tmpcounter);
1547 }
1548
1549 void pack_combos()
1550 {
1551 int32_t di = 0;
1552
1553 for(int32_t si=0; si<1024; si+=2)
1554 combobuf[di++] = combobuf[si];
1555
1556 for(; di<1024; di++)
1557 clear_combo(di);
1558 }
1559
1560 480 void reset_tunes(zctune *tune)
1561 {
1562
2/2
✓ Branch 0 taken 120960 times.
✓ Branch 1 taken 480 times.
121440 for(int32_t i=0; i<MAXCUSTOMTUNES; i++)
1563 {
1564 120960 tune[i].reset();
1565 120960 }
1566 480 }
1567
1568 int32_t doortranslations_u[9][4]=
1569 {
1570 {37,38,53,54},
1571 {37,38,39,40},
1572 {37,38,55,56},
1573 {37,38,39,40},
1574 {37,38,53,54},
1575 {37,38,53,54},
1576 {37,38,53,54},
1577 {7,8,23,24},
1578 {7,8,41,42}
1579 };
1580
1581 int32_t doortranslations_d[9][4]=
1582 {
1583 {117,118,133,134},
1584 {135,136,133,134},
1585 {119,120,133,134},
1586 {135,136,133,134},
1587 {117,118,133,134},
1588 {117,118,133,134},
1589 {117,118,133,134},
1590 {151,152,167,168},
1591 {137,138,167,168},
1592 };
1593
1594 //enum {dt_pass=0, dt_lock, dt_shut, dt_boss, dt_olck, dt_osht, dt_obos, dt_wall, dt_bomb, dt_walk, dt_max};
1595 int32_t doortranslations_l[9][6]=
1596 {
1597 {66,67,82,83,98,99},
1598 {66,68,82,84,98,100},
1599 {66,69,82,85,98,101},
1600 {66,68,82,84,98,100},
1601 {66,67,82,83,98,99},
1602 {66,67,82,83,98,99},
1603 {66,67,82,83,98,99},
1604 {64,65,80,81,96,97},
1605 {64,65,80,114,96,97},
1606 };
1607
1608 int32_t doortranslations_r[9][6]=
1609 {
1610
1611 {76,77,92,93,108,109},
1612 {75,77,91,93,107,109},
1613 {74,77,90,93,106,109},
1614 {75,77,91,93,107,109},
1615 {76,77,92,93,108,109},
1616 {76,77,92,93,108,109},
1617 {76,77,92,93,108,109},
1618 {78,79,94,95,110,111},
1619 {78,79,125,95,110,111},
1620 };
1621
1622 858450 int32_t tdcmbdat(int32_t map, int32_t scr, int32_t pos)
1623 {
1624 858450 byte old_cpage = old_combo_pages[map*MAPSCRS+scr];
1625 858450 return (TheMaps[map*MAPSCRS+TEMPLATE].data[pos]&0xFF) + (old_cpage<<8);
1626 }
1627
1628 840750 int32_t tdcmbcset(int32_t map, int32_t scr, int32_t pos)
1629 {
1630 //these are here to bypass compiler warnings about unused arguments
1631 840750 map=map;
1632 840750 scr=scr;
1633 840750 pos=pos;
1634
1635 //what does this function do?
1636 // return TheMaps[map*MAPSCRS+TEMPLATE].cset[pos];
1637 840750 return 2;
1638 }
1639
1640 22848 int32_t MakeDoors(int32_t map, int32_t scr)
1641 {
1642
2/2
✓ Branch 0 taken 18423 times.
✓ Branch 1 taken 4425 times.
22848 if(!(TheMaps[map*MAPSCRS+scr].valid&mVALID))
1643 {
1644 18423 return 0;
1645 }
1646
1647 4425 DoorComboSet tempdcs{};
1648
1649 //up
1650
2/2
✓ Branch 0 taken 39825 times.
✓ Branch 1 taken 4425 times.
44250 for(int32_t i=0; i<9; i++)
1651 {
1652
2/2
✓ Branch 0 taken 159300 times.
✓ Branch 1 taken 39825 times.
199125 for(int32_t j=0; j<4; j++)
1653 {
1654 159300 tempdcs.doorcombo_u[i][j]=tdcmbdat(map,scr,doortranslations_u[i][j]);
1655 159300 tempdcs.doorcset_u[i][j]=tdcmbcset(map,scr,doortranslations_u[i][j]);
1656 159300 }
1657 39825 }
1658
1659 4425 tempdcs.bombdoorcombo_u[0]=tdcmbdat(map,scr,57);
1660 4425 tempdcs.bombdoorcset_u[0]=tdcmbcset(map,scr,57);
1661 4425 tempdcs.bombdoorcombo_u[1]=tdcmbdat(map,scr,58);
1662 4425 tempdcs.bombdoorcset_u[1]=tdcmbcset(map,scr,58);
1663 4425 tempdcs.walkthroughcombo[0]=tdcmbdat(map,scr,34);
1664 4425 tempdcs.walkthroughcset[0]=tdcmbdat(map,scr,34);
1665
1666 //down
1667
2/2
✓ Branch 0 taken 39825 times.
✓ Branch 1 taken 4425 times.
44250 for(int32_t i=0; i<9; i++)
1668 {
1669
2/2
✓ Branch 0 taken 159300 times.
✓ Branch 1 taken 39825 times.
199125 for(int32_t j=0; j<4; j++)
1670 {
1671 159300 tempdcs.doorcombo_d[i][j]=tdcmbdat(map,scr,doortranslations_d[i][j]);
1672 159300 tempdcs.doorcset_d[i][j]=tdcmbcset(map,scr,doortranslations_d[i][j]);
1673 159300 }
1674 39825 }
1675
1676 4425 tempdcs.bombdoorcombo_d[0]=tdcmbdat(map,scr,121);
1677
1678 4425 tempdcs.bombdoorcset_d[0]=tdcmbcset(map,scr,121);
1679 4425 tempdcs.bombdoorcombo_d[1]=tdcmbdat(map,scr,122);
1680 4425 tempdcs.bombdoorcset_d[1]=tdcmbcset(map,scr,122);
1681 4425 tempdcs.walkthroughcombo[1]=tdcmbdat(map,scr,34);
1682 4425 tempdcs.walkthroughcset[1]=tdcmbdat(map,scr,34);
1683
1684 //left
1685 // TheMaps[i*MAPSCRS+j].warpdmap=TheOldMap.warpdmap;
1686
2/2
✓ Branch 0 taken 39825 times.
✓ Branch 1 taken 4425 times.
44250 for(int32_t i=0; i<9; i++)
1687 {
1688
2/2
✓ Branch 0 taken 238950 times.
✓ Branch 1 taken 39825 times.
278775 for(int32_t j=0; j<6; j++)
1689 {
1690 238950 tempdcs.doorcombo_l[i][j]=tdcmbdat(map,scr,doortranslations_l[i][j]);
1691 238950 tempdcs.doorcset_l[i][j]=tdcmbcset(map,scr,doortranslations_l[i][j]);
1692 238950 }
1693 39825 }
1694
1695
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4425 times.
4425 for(int32_t j=0; j>6; j++)
1696 {
1697 if((j!=2)&&(j!=3))
1698 {
1699 tempdcs.doorcombo_l[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].data[doortranslations_l[dt_bomb][j]];
1700 tempdcs.doorcset_l[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].cset[doortranslations_l[dt_bomb][j]];
1701 }
1702 }
1703
1704 4425 tempdcs.bombdoorcombo_l[0]=0;
1705 4425 tempdcs.bombdoorcset_l[0]=tdcmbcset(map,scr,115);
1706 4425 tempdcs.bombdoorcombo_l[1]=tdcmbdat(map,scr,115);
1707 4425 tempdcs.bombdoorcset_l[1]=tdcmbcset(map,scr,115);
1708 4425 tempdcs.bombdoorcombo_l[2]=0;
1709 4425 tempdcs.bombdoorcset_l[2]=tdcmbcset(map,scr,115);
1710 4425 tempdcs.walkthroughcombo[2]=tdcmbdat(map,scr,34);
1711 4425 tempdcs.walkthroughcset[2]=tdcmbdat(map,scr,34);
1712
1713 //right
1714
2/2
✓ Branch 0 taken 39825 times.
✓ Branch 1 taken 4425 times.
44250 for(int32_t i=0; i<9; i++)
1715 {
1716
2/2
✓ Branch 0 taken 238950 times.
✓ Branch 1 taken 39825 times.
278775 for(int32_t j=0; j<6; j++)
1717 {
1718 238950 tempdcs.doorcombo_r[i][j]=tdcmbdat(map,scr,doortranslations_r[i][j]);
1719 238950 tempdcs.doorcset_r[i][j]=tdcmbcset(map,scr,doortranslations_r[i][j]);
1720 238950 }
1721 39825 }
1722
1723
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4425 times.
4425 for(int32_t j=0; j>6; j++)
1724 {
1725 if((j!=2)&&(j!=3))
1726 {
1727 tempdcs.doorcombo_r[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].data[doortranslations_r[dt_bomb][j]];
1728 tempdcs.doorcset_r[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].cset[doortranslations_r[dt_bomb][j]];
1729 }
1730 }
1731
1732 4425 tempdcs.bombdoorcombo_r[0]=0;
1733 4425 tempdcs.bombdoorcset_r[0]=tdcmbcset(map,scr,124);
1734 4425 tempdcs.bombdoorcombo_r[1]=tdcmbdat(map,scr,124);
1735 4425 tempdcs.bombdoorcset_r[1]=tdcmbcset(map,scr,124);
1736 4425 tempdcs.bombdoorcombo_r[2]=0;
1737 4425 tempdcs.bombdoorcset_r[2]=tdcmbcset(map,scr,124);
1738 4425 tempdcs.walkthroughcombo[3]=tdcmbdat(map,scr,34);
1739 4425 tempdcs.walkthroughcset[3]=tdcmbdat(map,scr,34);
1740
1741 int32_t k;
1742
1743
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 10306 times.
10366 for(k=0; k<door_combo_set_count; k++)
1744 {
1745
2/2
✓ Branch 0 taken 5941 times.
✓ Branch 1 taken 4365 times.
10306 if(DoorComboSets[k]==tempdcs)
1746 {
1747 4365 break;
1748 }
1749 5941 }
1750
1751
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4425 times.
4425 if (k >= DoorComboSets.size())
1752 {
1753 return 0;
1754 }
1755
1756
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 4365 times.
4425 if(k==door_combo_set_count)
1757 {
1758 60 DoorComboSets[k]=tempdcs;
1759 60 DoorComboSetNames[k] = fmt::format("Door Combo Set {}", k);
1760 60 ++door_combo_set_count;
1761 60 }
1762
1763 4425 return k;
1764 /*
1765 doorcombo_u[9][4];
1766 doorcset_u[9][4];
1767 doorcombo_d[9][4];
1768 doorcset_d[9][4];
1769 doorcombo_l[9][6];
1770 doorcset_l[9][6];
1771 doorcombo_r[9][6];
1772 doorcset_r[9][6];
1773 bombdoorcombo_u[2];
1774 bombdoorcset_u[2];
1775 bombdoorcombo_d[2];
1776 bombdoorcset_d[2];
1777 bombdoorcombo_l[3];
1778 bombdoorcset_l[3];
1779 bombdoorcombo_r[3];
1780 bombdoorcset_r[3];
1781 walkthroughcombo[4];
1782 walkthroughcset[4];
1783 */
1784 22848 }
1785
1786 2924544 INLINE int32_t tcmbdat2(int32_t map, int32_t scr, int32_t pos)
1787 {
1788 2924544 byte old_cpage = old_combo_pages[map*MAPSCRS+scr];
1789 2924544 return (TheMaps[map*MAPSCRS+TEMPLATE2].data[pos]&0xFF) + (old_cpage<<8);
1790 }
1791
1792 2924544 INLINE int32_t tcmbcset2(int32_t map, int32_t pos)
1793 {
1794
1795 2924544 return TheMaps[map*MAPSCRS+TEMPLATE2].cset[pos];
1796 }
1797
1798 2924544 INLINE int32_t tcmbflag2(int32_t map, int32_t pos)
1799 {
1800 2924544 return TheMaps[map*MAPSCRS+TEMPLATE2].sflag[pos];
1801 }
1802
1803
1804 83 void get_questpwd(char *encrypted_pwd, int16_t pwdkey, char *pwd)
1805 {
1806 char temp_pwd[30];
1807 83 memset(temp_pwd,0,30);
1808
1809
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 8 times.
83 if(pwdkey!=0)
1810 {
1811 75 memcpy(temp_pwd,encrypted_pwd,30);
1812 75 temp_pwd[29]=0;
1813
1814
2/2
✓ Branch 0 taken 2250 times.
✓ Branch 1 taken 75 times.
2325 for(int32_t i=0; i<30; i++)
1815 {
1816 2250 temp_pwd[i] -= pwdkey;
1817 2250 int32_t t=pwdkey>>15;
1818 2250 pwdkey = (pwdkey<<1)+t;
1819 2250 }
1820 75 }
1821
1822 83 memcpy(pwd,temp_pwd,30);
1823 83 }
1824
1825
1826 257 bool devpwd()
1827 {
1828 #ifdef _DEBUG
1829 return true;
1830 #endif
1831 #if DEVLEVEL > 3
1832 return true;
1833 #endif
1834
1/2
✓ Branch 0 taken 257 times.
✗ Branch 1 not taken.
257 return !strcmp(zc_get_config("dev","pwd","",App::zquest), (char*)clavio) || is_ci();
1835 }
1836 bool check_questpwd(zquestheader *Header, char *pwd)
1837 {
1838 if(devpwd())
1839 return true;
1840 if((!strcmp(pwd, (char*)clavio)))
1841 return true;
1842 cvs_MD5Context ctx;
1843 uint8_t md5sum[16];
1844
1845 cvs_MD5Init(&ctx);
1846 cvs_MD5Update(&ctx, (const uint8_t*)pwd, (unsigned)strlen(pwd));
1847 cvs_MD5Final(md5sum, &ctx);
1848
1849 return (memcmp(Header->pwd_hash,md5sum,16)==0);
1850 }
1851
1852 static char const* key_exts[KEYFILE_NUMTY] = {"key", "zcheat", "zpwd"};
1853 static bool key_hashed[KEYFILE_NUMTY] = {false, true, false};
1854 static char const* key_namestr[KEYFILE_NUMTY] = {"Master","Cheat","ZPwd"};
1855
1856 static bool check_keyfile(char const* path, char const* ext, bool hashed, char const* typestr, zquestheader* Header)
1857 {
1858 char keyfilename[2048];
1859 replace_extension(keyfilename, path, ext, 2047);
1860 if(!exists(keyfilename))
1861 return false;
1862 bool ret = false;
1863
1864 char password[QSTPWD_LEN] = {0}, pwd[32] = {0};
1865 PACKFILE *fp = pack_fopen_password(keyfilename, F_READ,"");
1866 char msg[80] = {0};
1867 pfread(msg, 80, fp);
1868 if(strcmp(msg,"ZQuest Auto-Generated Quest Password Key File. DO NOT EDIT!"))
1869 {
1870 zprint2("Found %s Key File '%s' (invalid header)\n", typestr, keyfilename);
1871 pack_fclose(fp);
1872 return false;
1873 }
1874 int16_t ver;
1875 byte bld;
1876 p_igetw(&ver, fp);
1877 p_getc(&bld, fp);
1878 pfread(password, QSTPWD_LEN, fp, true);
1879 if(hashed)
1880 {
1881 char unhashed_pw[QSTPWD_LEN] = {0};
1882
1883 char hashmap = 'Z';
1884 hashmap += 'Q';
1885 hashmap += 'U';
1886 hashmap += 'E';
1887 hashmap += 'S';
1888 hashmap += 'T';
1889
1890 for ( int32_t q = 0; q < QSTPWD_LEN; ++q )
1891 unhashed_pw[q] = password[q] - hashmap;
1892
1893 ret = check_questpwd(Header, unhashed_pw);
1894 }
1895 else ret = check_questpwd(Header, password);
1896 pack_fclose(fp);
1897 zprint2("Found %s Key File '%s' (%s access)\n",
1898 typestr, keyfilename, ret ? "valid" : "invalid");
1899 return ret;
1900 }
1901
1902 bool check_keyfiles(char const* path, vector<uint> types, zquestheader* Header)
1903 {
1904 char exedir[PATH_MAX] = {0};
1905 extract_name(path, exedir, FILENAMEALL);
1906 char const* paths[] = {path, exedir};
1907 for(uint keyty : types)
1908 {
1909 if(keyty >= KEYFILE_NUMTY)
1910 continue;
1911 for(char const* p : paths)
1912 {
1913 if(check_keyfile(p, key_exts[keyty], key_hashed[keyty], key_namestr[keyty], Header))
1914 return true;
1915 }
1916 }
1917 return false;
1918 }
1919
1920 436 void print_quest_metadata(zquestheader const& tempheader, char const* path, byte qst_num)
1921 {
1922 436 zprint2("\n");
1923 436 zprint2("[QUEST METADATA]\n");
1924
1/2
✓ Branch 0 taken 436 times.
✗ Branch 1 not taken.
436 if(path)
1925 436 zprint2("Path: %s\n", path);
1926
2/2
✓ Branch 0 taken 328 times.
✓ Branch 1 taken 108 times.
436 if(tempheader.title[0])
1927 328 zprint2("Title: %s\n", tempheader.title);
1928 436 zprint2("ZC Version: %s\n", tempheader.getVerStr());
1929
2/2
✓ Branch 0 taken 177 times.
✓ Branch 1 taken 259 times.
436 if(tempheader.new_version_id_date_day)
1930 177 zprint2("ZC Build Date: %d-%d-%d %s %s\n", tempheader.new_version_id_date_year, tempheader.new_version_id_date_month, tempheader.new_version_id_date_day, tempheader.build_timestamp, tempheader.build_timezone);
1931
2/2
✓ Branch 0 taken 247 times.
✓ Branch 1 taken 189 times.
436 if(tempheader.version[0])
1932 247 zprint2("Qst Version: %s\n", tempheader.version);
1933
2/2
✓ Branch 0 taken 328 times.
✓ Branch 1 taken 108 times.
436 if(tempheader.author[0])
1934 328 zprint2("Author: %s\n", tempheader.author);
1935 436 zprint2("\n");
1936 436 }
1937
1938 816 int32_t readheader(PACKFILE *f, zquestheader *Header, byte printmetadata)
1939 {
1940 int32_t dummy;
1941 816 zquestheader tempheader{};
1942
2/2
✓ Branch 0 taken 804 times.
✓ Branch 1 taken 12 times.
816 tempheader.filename = Header->filename;
1943 char dummybuf[80];
1944 byte temp_map_count;
1945 byte temp_midi_flags[MIDIFLAGS_SIZE];
1946 word version;
1947 char temp_pwd[30], temp_pwd2[30];
1948 int16_t temp_pwdkey;
1949 cvs_MD5Context ctx;
1950 804 memset(temp_midi_flags, 0, MIDIFLAGS_SIZE);
1951 804 memset(FFCore.quest_format, 0, sizeof(FFCore.quest_format));
1952
1953
1954
1955
2/4
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 804 times.
804 if(!pfread(tempheader.id_str,sizeof(tempheader.id_str),f)) // first read old header
1956 {
1957 Z_message("Unable to read header string\n");
1958 return qe_invalid;
1959 }
1960
1961 // check header
1962
2/2
✓ Branch 0 taken 780 times.
✓ Branch 1 taken 24 times.
804 if(strcmp(tempheader.id_str,QH_NEWIDSTR))
1963 {
1964
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(strcmp(tempheader.id_str,QH_IDSTR))
1965 {
1966 Z_message("Invalid header string: '%s' (was expecting '%s' or '%s')\n", tempheader.id_str, QH_IDSTR, QH_NEWIDSTR);
1967 return qe_invalid;
1968 }
1969 24 }
1970
1971 804 int32_t templatepath_len=0;
1972
1973 804 tempheader.external_zinfo = false;
1974 804 read_zinfo = false;
1975
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 780 times.
804 if(!strcmp(tempheader.id_str,QH_IDSTR)) //pre-1.93 version
1976 {
1977 byte padding;
1978
1979
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&padding,f))
1980 {
1981 return qe_invalid;
1982 }
1983
1984
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_igetw(&tempheader.zelda_version,f))
1985 {
1986 return qe_invalid;
1987 }
1988
1989 24 FFCore.quest_format[vZelda] = tempheader.zelda_version;
1990
1991
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(tempheader.zelda_version > ZELDA_VERSION)
1992 {
1993 return qe_version;
1994 }
1995
1996 24 FFCore.quest_format[vZelda] = tempheader.zelda_version;
1997
1998
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(strcmp(tempheader.id_str,QH_IDSTR))
1999 {
2000 return qe_invalid;
2001 }
2002
2003
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(bad_version(tempheader.zelda_version))
2004 {
2005 return qe_obsolete;
2006 }
2007
2008
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
24 if(!p_igetw(&tempheader.internal,f))
2009 {
2010 return qe_invalid;
2011 }
2012
2013
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
24 if(!p_getc(&tempheader.quest_number,f))
2014 {
2015 return qe_invalid;
2016 }
2017
2018 24 FFCore.quest_format[qQuestNumber] = tempheader.quest_number;
2019
2020
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(&quest_rules[0],2,f))
2021 {
2022 return qe_invalid;
2023 }
2024
2025
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&temp_map_count,f))
2026 {
2027 return qe_invalid;
2028 }
2029
2030 24 FFCore.quest_format[qMapCount] = temp_map_count;
2031
2032
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&tempheader.old_str_count,f))
2033 {
2034 return qe_invalid;
2035 }
2036
2037
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
24 if(!p_getc(&tempheader.data_flags[ZQ_TILES],f))
2038 {
2039 return qe_invalid;
2040 }
2041
2042
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
24 if(!pfread(temp_midi_flags,4,f))
2043 {
2044 return qe_invalid;
2045 }
2046
2047
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&tempheader.data_flags[ZQ_CHEATS2],f))
2048 {
2049 return qe_invalid;
2050 }
2051
2052
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(dummybuf,14,f))
2053 {
2054 return qe_invalid;
2055 }
2056
2057
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(&quest_rules[2],2,f))
2058 {
2059 return qe_invalid;
2060 }
2061
2062
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&dummybuf,f))
2063 {
2064 return qe_invalid;
2065 }
2066
2067
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(tempheader.version,9,f))
2068 {
2069 return qe_invalid;
2070 }
2071
2072
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(tempheader.title,sizeof(tempheader.title),f))
2073 {
2074 return qe_invalid;
2075 }
2076 // These fields are expected to end in null bytes!
2077 24 tempheader.title[sizeof(tempheader.title)-1] = 0;
2078
2079
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(tempheader.author,sizeof(tempheader.author),f))
2080 {
2081 return qe_invalid;
2082 }
2083 24 tempheader.author[sizeof(tempheader.author)-1] = 0;
2084
2085
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&padding,f))
2086 {
2087 return qe_invalid;
2088 }
2089
2090
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_igetw(&temp_pwdkey,f))
2091 {
2092 return qe_invalid;
2093 }
2094
2095
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(temp_pwd,30,f))
2096 {
2097 return qe_invalid;
2098 }
2099
2100 24 get_questpwd(temp_pwd, temp_pwdkey, temp_pwd2);
2101
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 cvs_MD5Init(&ctx);
2102
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 cvs_MD5Update(&ctx, (const uint8_t*)temp_pwd2, (unsigned)strnlen(temp_pwd2, 30));
2103
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 cvs_MD5Final(tempheader.pwd_hash, &ctx);
2104
2105
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(tempheader.zelda_version < 0x177) // lacks new header stuff...
2106 {
2107 //memset(tempheader.minver,0,20); // char minver[9], byte build, byte foo[10]
2108 // Not anymore...
2109 memset(tempheader.minver,0,17);
2110 tempheader.build=0;
2111 tempheader.use_keyfile=0;
2112 memset(tempheader.old_foo, 0, 9);
2113 }
2114 else
2115 {
2116
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(tempheader.minver,9,f))
2117 {
2118 return qe_invalid;
2119 }
2120
2121
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&tempheader.build,f))
2122 {
2123 return qe_invalid;
2124 }
2125
2126 24 FFCore.quest_format[vBuild] = tempheader.build;
2127
2128
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&tempheader.use_keyfile,f))
2129 {
2130 return qe_invalid;
2131 }
2132
2133
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(dummybuf,9,f))
2134 {
2135 return qe_invalid;
2136 }
2137 } // starting at minver
2138
2139
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 6 times.
24 if(tempheader.zelda_version < 0x187) // lacks newer header stuff...
2140 {
2141 6 memset(&quest_rules[4],0,16); // word rules3..rules10
2142 6 }
2143 else
2144 {
2145
2/4
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
18 if(!pfread(&quest_rules[4],16,f)) // read new header additions
2146 {
2147 return qe_invalid; // starting at rules3
2148 }
2149
2150
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 6 times.
18 if(tempheader.zelda_version <= 0x190)
2151 {
2152
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 set_qr(qr_MEANPLACEDTRAPS,0);
2153 12 }
2154 }
2155
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 unpack_qrs();
2156
2157
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
30 if((tempheader.zelda_version < 0x192)||
2158
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((tempheader.zelda_version == 0x192)&&(tempheader.build<149)))
2159 {
2160
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 6 times.
24 set_qr(qr_BRKNSHLDTILES,(get_qr(qr_BRKBLSHLDS_DEP)));
2161
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 set_bit(deprecated_rules,qr_BRKBLSHLDS_DEP,(get_qr(qr_BRKBLSHLDS_DEP)));
2162
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 set_qr(qr_BRKBLSHLDS_DEP,0);
2163 18 }
2164
2165
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 12 times.
18 if(tempheader.zelda_version >= 0x192) // lacks newer header stuff...
2166 {
2167 6 byte *mf=temp_midi_flags;
2168
2169
3/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 4 times.
6 if((tempheader.zelda_version == 0x192)&&(tempheader.build<178))
2170 {
2171 4 mf=(byte*)dummybuf;
2172 4 }
2173
2174
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!pfread(mf,32,f)) // read new header additions
2175 {
2176 return qe_invalid; // starting at foo2
2177 }
2178
2179
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!pfread(dummybuf,18,f)) // read new header additions
2180 {
2181 return qe_invalid; // starting at foo2
2182 }
2183 6 }
2184
2185
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 12 times.
24 if((tempheader.zelda_version < 0x192)||
2186
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((tempheader.zelda_version == 0x192)&&(tempheader.build<145)))
2187 {
2188 18 memset(tempheader.templatepath,0,2048);
2189 18 }
2190 else
2191 {
2192 if(!pfread(tempheader.templatepath,280,f)) // read templatepath
2193 {
2194 return qe_invalid;
2195 }
2196 }
2197
2198
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
30 if((tempheader.zelda_version < 0x192)||
2199
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((tempheader.zelda_version == 0x192)&&(tempheader.build<186)))
2200 {
2201 24 tempheader.use_keyfile=0;
2202 24 }
2203 24 }
2204 else
2205 {
2206 //section id
2207
2/4
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 780 times.
✗ Branch 3 not taken.
780 if(!p_mgetl(&dummy,f))
2208 {
2209 return qe_invalid;
2210 }
2211
2212 //section version info
2213
2/4
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 780 times.
✗ Branch 3 not taken.
780 if(!p_igetw(&version,f))
2214 {
2215 return qe_invalid;
2216 }
2217
2218 780 FFCore.quest_format[vHeader] = version;
2219
2220
2/4
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 780 times.
✗ Branch 3 not taken.
780 if(!p_igetw(&dummy,f))
2221 {
2222 return qe_invalid;
2223 }
2224
2225 //section size
2226
2/4
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 780 times.
✗ Branch 3 not taken.
780 if(!p_igetl(&dummy,f))
2227 {
2228 return qe_invalid;
2229 }
2230
2231 //finally... section data
2232
2/4
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 780 times.
✗ Branch 3 not taken.
780 if(!p_igetw(&tempheader.zelda_version,f))
2233 {
2234 return qe_invalid;
2235 }
2236
2237 780 FFCore.quest_format[vZelda] = tempheader.zelda_version;
2238
2239 //do some quick checking...
2240
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 780 times.
780 if(tempheader.zelda_version > ZELDA_VERSION)
2241 {
2242 return qe_version;
2243 }
2244
2245
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 780 times.
780 if(strcmp(tempheader.id_str,QH_NEWIDSTR))
2246 {
2247 return qe_invalid;
2248 }
2249
2250
2/4
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 780 times.
780 if(bad_version(tempheader.zelda_version))
2251 {
2252 return qe_obsolete;
2253 }
2254
2255
2/4
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 780 times.
✗ Branch 3 not taken.
780 if(!p_getc(&tempheader.build,f))
2256 {
2257 return qe_invalid;
2258 }
2259
2260 780 FFCore.quest_format[vBuild] = tempheader.build;
2261
2262
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 721 times.
780 if(version<3)
2263 {
2264
2/4
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 59 times.
✗ Branch 3 not taken.
59 if(!pfread(temp_pwd,30,f))
2265 {
2266 return qe_invalid;
2267 }
2268
2269
2/4
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 59 times.
✗ Branch 3 not taken.
59 if(!p_igetw(&temp_pwdkey,f))
2270 {
2271 return qe_invalid;
2272 }
2273
2274 59 get_questpwd(temp_pwd, temp_pwdkey, temp_pwd2);
2275
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 cvs_MD5Init(&ctx);
2276
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 cvs_MD5Update(&ctx, (const uint8_t*)temp_pwd2, (unsigned)strnlen(temp_pwd2, 30));
2277
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 cvs_MD5Final(tempheader.pwd_hash, &ctx);
2278 59 }
2279 else
2280 {
2281
2/4
✓ Branch 0 taken 721 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 721 times.
721 if(!pfread(tempheader.pwd_hash,sizeof(tempheader.pwd_hash),f))
2282 {
2283 return qe_invalid;
2284 }
2285 }
2286
2287
2/4
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 780 times.
✗ Branch 3 not taken.
780 if(!p_igetw(&tempheader.internal,f))
2288 {
2289 return qe_invalid;
2290 }
2291
2292
2/4
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 780 times.
✗ Branch 3 not taken.
780 if(!p_getc(&tempheader.quest_number,f))
2293 {
2294 return qe_invalid;
2295 }
2296
2297 780 FFCore.quest_format[qQuestNumber] = tempheader.quest_number;
2298
2299 780 size_t versz = version < 8 ? 9 : 16;
2300
2/4
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 780 times.
✗ Branch 3 not taken.
780 if(!pfread(tempheader.version,versz,f))
2301 {
2302 return qe_invalid;
2303 }
2304
2305 //FFCore.quest_format[qQuestVersion] = tempheader.version;
2306 //needs to be copied as char[9] or stored as a s.str
2307
2/4
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 780 times.
✗ Branch 3 not taken.
780 if(!pfread(tempheader.minver,versz,f))
2308 {
2309 return qe_invalid;
2310 }
2311
2312 //FFCore.quest_format[qMinQuestVersion] = tempheader.minver;
2313
2/4
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 780 times.
✗ Branch 3 not taken.
780 if(!pfread(tempheader.title,sizeof(tempheader.title),f))
2314 {
2315 return qe_invalid;
2316 }
2317 780 tempheader.title[sizeof(tempheader.title)-1] = 0;
2318
2319
2/4
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 780 times.
✗ Branch 3 not taken.
780 if(!pfread(tempheader.author,sizeof(tempheader.author),f))
2320 {
2321 return qe_invalid;
2322 }
2323 780 tempheader.author[sizeof(tempheader.author)-1] = 0;
2324
2325
2/4
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 780 times.
✗ Branch 3 not taken.
780 if(!p_getc(&tempheader.use_keyfile,f))
2326 {
2327 return qe_invalid;
2328 }
2329
2330 /*
2331 if(!pfread(tempheader.data_flags,sizeof(tempheader.data_flags),f))
2332 {
2333 return qe_invalid;
2334 }
2335 */
2336
2/4
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 780 times.
✗ Branch 3 not taken.
780 if(!p_getc(&tempheader.data_flags[ZQ_TILES],f))
2337 {
2338 return qe_invalid;
2339 }
2340
2341
2/4
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 780 times.
✗ Branch 3 not taken.
780 if(!pfread(&dummybuf,4,f))
2342 {
2343 return qe_invalid;
2344 }
2345
2346
2/4
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 780 times.
✗ Branch 3 not taken.
780 if(!p_getc(&tempheader.data_flags[ZQ_CHEATS2],f))
2347 {
2348 return qe_invalid;
2349 }
2350
2351
2/4
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 780 times.
✗ Branch 3 not taken.
780 if(!pfread(dummybuf,14,f))
2352 {
2353 return qe_invalid;
2354 }
2355
2356 780 templatepath_len=sizeof(tempheader.templatepath);
2357
2358
2/2
✓ Branch 0 taken 721 times.
✓ Branch 1 taken 59 times.
780 if(version==1)
2359 {
2360 59 templatepath_len=280;
2361 59 }
2362
2363
2/4
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 780 times.
✗ Branch 3 not taken.
780 if(!pfread(tempheader.templatepath,templatepath_len,f))
2364 {
2365 return qe_invalid;
2366 }
2367
2368
2/4
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 780 times.
✗ Branch 3 not taken.
780 if(!p_getc(&temp_map_count,f))
2369 {
2370 return qe_invalid;
2371 }
2372
2373
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 588 times.
780 if(version>=4)
2374 {
2375
2/4
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 192 times.
✗ Branch 3 not taken.
192 if(!p_igetl(&tempheader.version_major,f))
2376 {
2377 return qe_invalid;
2378 }
2379
2/4
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 192 times.
✗ Branch 3 not taken.
192 if(!p_igetl(&tempheader.version_minor,f))
2380 {
2381 return qe_invalid;
2382 }
2383
2/4
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 192 times.
✗ Branch 3 not taken.
192 if(!p_igetl(&tempheader.version_patch,f))
2384 {
2385 return qe_invalid;
2386 }
2387
2/4
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 192 times.
✗ Branch 3 not taken.
192 if(!p_igetl(&tempheader.new_version_id_fourth,f))
2388 {
2389 return qe_invalid;
2390 }
2391
2/4
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 192 times.
✗ Branch 3 not taken.
192 if(!p_igetl(&tempheader.new_version_id_alpha,f))
2392 {
2393 return qe_invalid;
2394 }
2395
2/4
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 192 times.
✗ Branch 3 not taken.
192 if(!p_igetl(&tempheader.new_version_id_beta,f))
2396 {
2397 return qe_invalid;
2398 }
2399
2/4
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 192 times.
✗ Branch 3 not taken.
192 if(!p_igetl(&tempheader.new_version_id_gamma,f))
2400 {
2401 return qe_invalid;
2402 }
2403
2/4
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 192 times.
✗ Branch 3 not taken.
192 if(!p_igetl(&tempheader.new_version_id_release,f))
2404 {
2405 return qe_invalid;
2406 }
2407
2408 // 2.55 alpha 86 incorrectly used 56 as the second version component. Fix that here.
2409
3/6
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 148 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 44 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
192 if (tempheader.version_major == 2 && tempheader.version_minor == 56 && tempheader.new_version_id_alpha == 86)
2410 tempheader.version_minor = 55;
2411
2412
2/4
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 192 times.
✗ Branch 3 not taken.
192 if(!p_igetw(&tempheader.new_version_id_date_year,f))
2413 {
2414 return qe_invalid;
2415 }
2416
2/4
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 192 times.
✗ Branch 3 not taken.
192 if(!p_getc(&tempheader.new_version_id_date_month,f))
2417 {
2418 return qe_invalid;
2419 }
2420
2/4
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 192 times.
✗ Branch 3 not taken.
192 if(!p_getc(&tempheader.new_version_id_date_day,f))
2421 {
2422 return qe_invalid;
2423 }
2424
2/4
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 192 times.
✗ Branch 3 not taken.
192 if(!p_getc(&tempheader.new_version_id_date_hour,f))
2425 {
2426 return qe_invalid;
2427 }
2428
2/4
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 192 times.
✗ Branch 3 not taken.
192 if(!p_getc(&tempheader.new_version_id_date_minute,f))
2429 {
2430 return qe_invalid;
2431 }
2432
2433
2/4
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 192 times.
✗ Branch 3 not taken.
192 if(!pfread(tempheader.new_version_devsig,256,f))
2434 {
2435 return qe_invalid;
2436 }
2437
1/2
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
192 if(!strcmp(tempheader.new_version_devsig, "Venrob"))
2438 strcpy(tempheader.new_version_devsig, "EmilyV99");
2439
2/4
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 192 times.
✗ Branch 3 not taken.
192 if(!pfread(tempheader.new_version_compilername,256,f))
2440 {
2441 return qe_invalid;
2442 }
2443
2/4
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 192 times.
✗ Branch 3 not taken.
192 if(!pfread(tempheader.new_version_compilerversion,256,f))
2444 {
2445 return qe_invalid;
2446 }
2447
2/4
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 192 times.
✗ Branch 3 not taken.
192 if(!pfread(tempheader.product_name,1024,f))
2448 {
2449 return qe_invalid;
2450 }
2451
2452
2/4
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 192 times.
✗ Branch 3 not taken.
192 if(!p_getc(&tempheader.compilerid,f))
2453 {
2454 return qe_invalid;
2455 }
2456
2/4
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 192 times.
✗ Branch 3 not taken.
192 if(!p_igetl(&tempheader.compilerversionnumber_first,f))
2457 {
2458 return qe_invalid;
2459 }
2460
2/4
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 192 times.
✗ Branch 3 not taken.
192 if(!p_igetl(&tempheader.compilerversionnumber_second,f))
2461 {
2462 return qe_invalid;
2463 }
2464
2/4
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 192 times.
✗ Branch 3 not taken.
192 if(!p_igetl(&tempheader.compilerversionnumber_third,f))
2465 {
2466 return qe_invalid;
2467 }
2468
2/4
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 192 times.
✗ Branch 3 not taken.
192 if(!p_igetl(&tempheader.compilerversionnumber_fourth,f))
2469 {
2470 return qe_invalid;
2471 }
2472
2/4
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 192 times.
✗ Branch 3 not taken.
192 if(!p_igetw(&tempheader.developerid,f))
2473 {
2474 return qe_invalid;
2475 }
2476
2/4
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 192 times.
192 if(!pfread(tempheader.made_in_module_name,1024,f))
2477 {
2478 return qe_invalid;
2479 }
2480
2/4
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 192 times.
192 if(!pfread(tempheader.build_datestamp,256,f))
2481 {
2482 return qe_invalid;
2483 }
2484
2/4
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 192 times.
192 if(!pfread(tempheader.build_timestamp,256,f))
2485 {
2486 return qe_invalid;
2487 }
2488 192 }
2489 else // <4
2490 {
2491 588 tempheader.version_major = 0;
2492 588 tempheader.version_minor = 0;
2493 588 tempheader.version_patch = 0;
2494 588 tempheader.new_version_id_fourth = 0;
2495 588 tempheader.new_version_id_alpha = 0;
2496 588 tempheader.new_version_id_beta = 0;
2497 588 tempheader.new_version_id_gamma = 0;
2498 588 tempheader.new_version_id_release = 0;
2499 588 tempheader.new_version_id_date_year = 0;
2500 588 tempheader.new_version_id_date_month = 0;
2501 588 tempheader.new_version_id_date_day = 0;
2502 588 tempheader.new_version_id_date_hour = 0;
2503 588 tempheader.new_version_id_date_minute = 0;
2504
2505 588 memset(tempheader.new_version_devsig, 0, 256);
2506 588 memset(tempheader.new_version_compilername, 0, 256);
2507 588 memset(tempheader.new_version_compilerversion, 0, 256);
2508 588 memset(tempheader.product_name, 0, 1024);
2509 588 strcpy(tempheader.product_name, "ZQuest Classic");
2510
2511 588 tempheader.compilerid = 0;
2512 588 tempheader.compilerversionnumber_first = 0;
2513 588 tempheader.compilerversionnumber_second = 0;
2514 588 tempheader.compilerversionnumber_third = 0;
2515 588 tempheader.compilerversionnumber_fourth = 0;
2516 588 tempheader.developerid = 0;
2517
2518 588 memset(tempheader.made_in_module_name, 0, 1024);
2519 588 memset(tempheader.build_datestamp, 0, 256);
2520 588 memset(tempheader.build_timestamp, 0, 256);
2521 }
2522
2523
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 588 times.
780 if ( version >= 5 )
2524 {
2525
2/4
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 192 times.
✗ Branch 3 not taken.
192 if(!pfread(tempheader.build_timezone,6,f))
2526 {
2527 return qe_invalid;
2528 }
2529 192 }
2530 else // < 5
2531 {
2532 588 memset(tempheader.build_timezone, 0, 6);
2533 }
2534
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 588 times.
780 if ( version >= 6 )
2535 {
2536 byte b;
2537
2/4
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 192 times.
✗ Branch 3 not taken.
192 if(!p_getc(&b,f))
2538 {
2539 return qe_invalid;
2540 }
2541 192 tempheader.external_zinfo = b?true:false;
2542 192 read_zinfo = true;
2543 192 }
2544
2545
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 588 times.
780 if(version >= 7)
2546 {
2547
2/4
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 192 times.
✗ Branch 3 not taken.
192 if(!p_getc(&(tempheader.new_version_is_nightly),f))
2548 {
2549 return qe_invalid;
2550 }
2551 192 }
2552 else
2553 {
2554 588 tempheader.new_version_is_nightly = false;
2555
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 588 times.
588 if(tempheader.zelda_version < 0x255)
2556 {
2557
2/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 529 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 59 times.
588 switch(tempheader.zelda_version)
2558 {
2559 case 0x254:
2560 tempheader.version_major = 2;
2561 tempheader.version_minor = 54;
2562 break;
2563 case 0x250:
2564
7/16
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 33 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 24 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 6 times.
✓ Branch 11 taken 405 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 16 times.
✓ Branch 14 taken 29 times.
✓ Branch 15 taken 16 times.
529 switch(tempheader.build)
2565 {
2566 case 19:
2567 tempheader.version_major = 2;
2568 tempheader.version_minor = 50;
2569 tempheader.new_version_id_gamma = 1;
2570 break;
2571 case 20:
2572 tempheader.version_major = 2;
2573 tempheader.version_minor = 50;
2574 tempheader.new_version_id_gamma = 2;
2575 break;
2576 case 21:
2577 tempheader.version_major = 2;
2578 tempheader.version_minor = 50;
2579 tempheader.new_version_id_gamma = 3;
2580 break;
2581 case 22:
2582 tempheader.version_major = 2;
2583 tempheader.version_minor = 50;
2584 tempheader.new_version_id_gamma = 4;
2585 break;
2586 case 23:
2587 tempheader.version_major = 2;
2588 tempheader.version_minor = 50;
2589 tempheader.new_version_id_gamma = 5;
2590 break;
2591 case 24:
2592 33 tempheader.version_major = 2;
2593 33 tempheader.version_minor = 50;
2594 33 tempheader.new_version_id_release = -1;
2595 33 break;
2596 case 25:
2597 tempheader.version_major = 2;
2598 tempheader.version_minor = 50;
2599 tempheader.version_patch = 1;
2600 tempheader.new_version_id_gamma = 1;
2601 break;
2602 case 26:
2603 24 tempheader.version_major = 2;
2604 24 tempheader.version_minor = 50;
2605 24 tempheader.version_patch = 1;
2606 24 tempheader.new_version_id_gamma = 2;
2607 24 break;
2608 case 27:
2609 tempheader.version_major = 2;
2610 tempheader.version_minor = 50;
2611 tempheader.version_patch = 1;
2612 tempheader.new_version_id_gamma = 3;
2613 break;
2614 case 28:
2615 6 tempheader.version_major = 2;
2616 6 tempheader.version_minor = 50;
2617 6 tempheader.version_patch = 1;
2618 6 tempheader.new_version_id_release = -1;
2619 6 break;
2620 case 29:
2621 405 tempheader.version_major = 2;
2622 405 tempheader.version_minor = 50;
2623 405 tempheader.version_patch = 2;
2624 405 tempheader.new_version_id_release = -1;
2625 405 break;
2626 case 30:
2627 tempheader.version_major = 2;
2628 tempheader.version_minor = 50;
2629 tempheader.version_patch = 3;
2630 tempheader.new_version_id_gamma = 1;
2631 break;
2632 case 31:
2633 16 tempheader.version_major = 2;
2634 16 tempheader.version_minor = 53;
2635 16 tempheader.new_version_id_gamma = -1;
2636 16 break;
2637 case 32:
2638 29 tempheader.version_major = 2;
2639 29 tempheader.version_minor = 53;
2640 29 tempheader.new_version_id_release = -1;
2641 29 break;
2642 case 33:
2643 16 tempheader.version_major = 2;
2644 16 tempheader.version_minor = 53;
2645 16 tempheader.version_patch = 1;
2646 16 break;
2647 }
2648 529 break;
2649
2650 case 0x211:
2651 tempheader.version_major = 2;
2652 tempheader.version_minor = 11;
2653 tempheader.new_version_id_beta = tempheader.build;
2654 break;
2655 case 0x210:
2656 59 tempheader.version_major = 2;
2657 59 tempheader.version_minor = 10;
2658 59 tempheader.new_version_id_beta = tempheader.build;
2659 59 break;
2660 }
2661 588 }
2662 }
2663
2664
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 632 times.
780 if (version>=9)
2665 {
2666 148 std::string version_string;
2667
2/4
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 148 times.
✗ Branch 3 not taken.
148 if(!p_getcstr(&version_string, f))
2668 {
2669 return qe_invalid;
2670 }
2671
2672 148 strncpy(tempheader.zelda_version_string, version_string.c_str(), sizeof(tempheader.zelda_version_string));
2673 148 snprintf(tempheader.zelda_version_string, sizeof(tempheader.zelda_version_string), "%s", version_string.c_str());
2674
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 }
2675 else
2676 {
2677 632 snprintf(tempheader.zelda_version_string, sizeof(tempheader.zelda_version_string), "%d.%d.%d", tempheader.version_major, tempheader.version_minor, tempheader.version_patch);
2678 }
2679 }
2680
2681
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 792 times.
804 if(printmetadata)
2682 {
2683
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 print_quest_metadata(tempheader, loading_qst_name, loading_qst_num);
2684 12 }
2685
2686 //{ Version Warning
2687
1/2
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
804 int32_t vercmp = tempheader.compareVer();
2688
3/6
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 804 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 804 times.
✗ Branch 5 not taken.
804 int32_t astatecmp = compare(int32_t(tempheader.getAlphaState()), getAlphaState());
2689
2/4
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 804 times.
✗ Branch 3 not taken.
804 int32_t avercmp = compare(tempheader.getAlphaVer(), 0);
2690
4/6
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 148 times.
✓ Branch 3 taken 656 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 148 times.
952 if(vercmp > 0 || (!vercmp &&
2691
2/4
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 148 times.
✗ Branch 3 not taken.
148 (astatecmp > 0 || (!astatecmp &&
2692 148 avercmp > 0))))
2693 {
2694 bool r = true;
2695 if(loadquest_report)
2696 {
2697 enter_sys_pal();
2698 AlertDialog("Quest saved in newer version",
2699 "This quest was last saved in a newer version of ZQuest."
2700 " Attempting to load this quest may not work correctly; to"
2701 " avoid issues, try loading this quest in at least '" + std::string(tempheader.getVerStr()) + "'"
2702 "\n\nWould you like to continue loading anyway? (Not recommended)",
2703 [&](bool ret,bool)
2704 {
2705 r = ret;
2706 }).show();
2707 exit_sys_pal();
2708 }
2709 if(!r)
2710 return qe_silenterr;
2711 }
2712
2/4
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 804 times.
✗ Branch 3 not taken.
804 else if(tempheader.compareDate() > 0)
2713 {
2714 bool r = true;
2715 if(loadquest_report)
2716 {
2717 enter_sys_pal();
2718 AlertDialog("Quest saved in newer build",
2719 fmt::format("This quest was last saved in a newer build of ZQuest, and may have"
2720 " issues loading in this build."
2721 "\n{}"
2722 "\n\nWould you like to continue loading anyway?",
2723 tempheader.getVerCmpStr()),
2724 [&](bool ret,bool)
2725 {
2726 r = ret;
2727 }).show();
2728 exit_sys_pal();
2729 }
2730 if(!r)
2731 return qe_silenterr;
2732 }
2733 //}
2734
2735 804 read_ext_zinfo = tempheader.external_zinfo;
2736
2737
1/2
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
804 *Header = tempheader;
2738 804 map_count=temp_map_count;
2739 804 memcpy(midi_flags, temp_midi_flags, MIDIFLAGS_SIZE);
2740
2741
1/2
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
804 unpack_qrs();
2742
2743 804 return 0;
2744 828 }
2745
2746 9344 int32_t readrules(PACKFILE *f, zquestheader *Header)
2747 {
2748
2/2
✓ Branch 0 taken 9321 times.
✓ Branch 1 taken 23 times.
9344 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_rules);
2749
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9344 times.
9344 if (should_skip)
2750 return 0;
2751
2752 int32_t dummy;
2753 9344 zquestheader tempheader = *Header;
2754 9344 word s_version=0;
2755 9344 dword compatrule_version=0;
2756
2757
2/2
✓ Branch 0 taken 457 times.
✓ Branch 1 taken 8887 times.
9344 if(tempheader.zelda_version >= 0x193)
2758 {
2759 //section version info
2760
2/4
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 457 times.
✗ Branch 3 not taken.
457 if(!p_igetw(&s_version,f))
2761 {
2762 return qe_invalid;
2763 }
2764
2765 457 FFCore.quest_format[vRules] = s_version;
2766
2767
2/4
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 457 times.
✗ Branch 3 not taken.
457 if(!p_igetw(&dummy,f))
2768 {
2769 return qe_invalid;
2770 }
2771
2772
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 265 times.
457 if(s_version > 16)
2773 {
2774
2/4
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 192 times.
✗ Branch 3 not taken.
192 if(!p_igetl(&compatrule_version,f))
2775 {
2776 return qe_invalid;
2777 }
2778 192 }
2779 457 FFCore.quest_format[vCompatRule] = compatrule_version;
2780
2781 //section size
2782
2/4
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 457 times.
✗ Branch 3 not taken.
457 if(!p_igetl(&dummy,f))
2783 {
2784 return qe_invalid;
2785 }
2786
2787
2/2
✓ Branch 0 taken 265 times.
✓ Branch 1 taken 192 times.
457 if ( s_version < 15 )
2788 {
2789 //finally... section data
2790
2/4
✓ Branch 0 taken 265 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 265 times.
✗ Branch 3 not taken.
265 if(!pfread(quest_rules,QUESTRULES_SIZE,f))
2791 {
2792 return qe_invalid;
2793 }
2794 265 }
2795 else
2796 {
2797
2798
2/4
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 192 times.
✗ Branch 3 not taken.
192 if(!pfread(quest_rules,QUESTRULES_NEW_SIZE,f))
2799 {
2800 return qe_invalid;
2801 }
2802
2803 }
2804 457 }
2805
2806 //{ bunch of compat stuff
2807 9344 memcpy(deprecated_rules, quest_rules, QUESTRULES_NEW_SIZE);
2808
2809
2/2
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 8864 times.
9344 unpack_qrs();
2810
2811
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 398 times.
480 if(s_version<2)
2812 {
2813
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(14,0);
2814
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(27,0);
2815
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(28,0);
2816
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(29,0);
2817
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(30,0);
2818
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(32,0);
2819
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(36,0);
2820
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(49,0);
2821
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(50,0);
2822
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(51,0);
2823
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(68,0);
2824
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(75,0);
2825
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(76,0);
2826
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(98,0);
2827
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(110,0);
2828
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(113,0);
2829
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(116,0);
2830
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(102,0);
2831
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(132,0);
2832 82 }
2833
2834 //Now, do any updates...
2835
3/4
✓ Branch 0 taken 398 times.
✓ Branch 1 taken 82 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 398 times.
480 if((tempheader.zelda_version < 0x211)||((tempheader.zelda_version == 0x211)&&(tempheader.build<18)))
2836 {
2837
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_SMOOTHVERTICALSCROLLING,1);
2838
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_REPLACEOPENDOORS, 1);
2839
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_OLDLENSORDER, 1);
2840
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_NOFAIRYGUYFIRES, 1);
2841
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_TRIGGERSREPEAT, 1);
2842 82 }
2843
2844
3/4
✓ Branch 0 taken 457 times.
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 457 times.
480 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<3)))
2845 {
2846
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_qr(qr_WALLFLIERS,1);
2847 23 }
2848
2849
3/4
✓ Branch 0 taken 457 times.
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 457 times.
480 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<4)))
2850 {
2851
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_qr(qr_NOBOMBPALFLASH,1);
2852 23 }
2853
2854
3/4
✓ Branch 0 taken 457 times.
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 457 times.
480 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<3)))
2855 {
2856
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_qr(qr_NOSCROLLCONTINUE,1);
2857 23 }
2858
2859
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 398 times.
480 if(tempheader.zelda_version <= 0x210)
2860 {
2861
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_ARROWCLIP,1);
2862 82 }
2863
2864
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 421 times.
480 if(tempheader.zelda_version == 0x210)
2865 {
2866
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 set_qr(qr_NOSCROLLCONTINUE, get_qr(qr_CMBCYCLELAYERS));
2867
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 set_qr(qr_CMBCYCLELAYERS, 0);
2868
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 set_qr(qr_CONT_SWORD_TRIGGERS, 1);
2869 59 }
2870
2871
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 398 times.
480 if(tempheader.zelda_version <= 0x210)
2872 {
2873
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_OLDSTYLEWARP,1);
2874
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_210_WARPRETURN,1);
2875 82 }
2876
2877 //might not be correct
2878
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 457 times.
480 if(tempheader.zelda_version < 0x210)
2879 {
2880
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_bit(deprecated_rules, qr_OLDTRIBBLES_DEP,1);
2881
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_qr(qr_OLDTRIBBLES_DEP,1);
2882
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_qr(qr_OLDHOOKSHOTGRAB,1);
2883 23 }
2884
2885
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 398 times.
480 if(tempheader.zelda_version < 0x211)
2886 {
2887
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_WRONG_BRANG_TRAIL_DIR,1);
2888 82 }
2889
2890
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 475 times.
480 if((tempheader.zelda_version == 0x192 && tempheader.build <= 163) || tempheader.zelda_version < 0x192)
2891 {
2892
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 458 times.
480 set_qr(qr_192b163_WARP,1);
2893 22 }
2894
2895
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 47 times.
22 if(tempheader.zelda_version == 0x210)
2896 {
2897
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 set_bit(deprecated_rules, qr_OLDTRIBBLES_DEP, get_qr(qr_DMGCOMBOPRI));
2898
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 set_qr(qr_OLDTRIBBLES_DEP, get_qr(qr_DMGCOMBOPRI));
2899
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 set_qr(qr_DMGCOMBOPRI, 0);
2900 59 }
2901
2902
3/4
✓ Branch 0 taken 398 times.
✓ Branch 1 taken 292 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 398 times.
106 if(tempheader.zelda_version < 0x211 || (tempheader.zelda_version == 0x211 && tempheader.build<15))
2903 {
2904
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 210 times.
292 set_qr(qr_OLDPICKUP,1);
2905 82 }
2906
2907
3/4
✓ Branch 0 taken 398 times.
✓ Branch 1 taken 82 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 398 times.
480 if(tempheader.zelda_version < 0x211 || (tempheader.zelda_version == 0x211 && tempheader.build < 18))
2908 {
2909
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_NOSOLIDDAMAGECOMBOS, 1);
2910
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_ITEMPICKUPSETSBELOW, 1); // broke around build 400
2911 82 }
2912
2913
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 398 times.
480 if(tempheader.zelda_version < 0x250) // version<0x250 checks for beta 18; build was set to 18 prematurely
2914 {
2915
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_HOOKSHOTDOWNBUG, 1);
2916 82 }
2917
2918
4/4
✓ Branch 0 taken 206 times.
✓ Branch 1 taken 274 times.
✓ Branch 2 taken 33 times.
✓ Branch 3 taken 173 times.
480 if(tempheader.zelda_version == 0x250 && tempheader.build == 24) // Annoying...
2919 {
2920
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 set_qr(qr_PEAHATCLOCKVULN, 1);
2921 33 }
2922
2923
4/4
✓ Branch 0 taken 398 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 206 times.
✓ Branch 3 taken 192 times.
480 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 22)) //22 is 2.50.0 RC4. Gotta set the door repair QR... -Dimi
2924 {
2925
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 206 times.
288 set_qr(qr_OLD_DOORREPAIR, 1);
2926 82 }
2927
2928
4/4
✓ Branch 0 taken 398 times.
✓ Branch 1 taken 124 times.
✓ Branch 2 taken 206 times.
✓ Branch 3 taken 192 times.
274 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 20)) //20 is 2.50.0 RC1 and RC2 (cause it didn't get bumped). Okay I'm gonna be honest I have no idea if any 2.50 build was available before RC1, but gonna try and cover my ass here -Dimi
2929 {
2930
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 248 times.
330 set_qr(qr_OLD_SECRETMONEY, 1);
2931 82 }
2932
2933
4/4
✓ Branch 0 taken 398 times.
✓ Branch 1 taken 124 times.
✓ Branch 2 taken 206 times.
✓ Branch 3 taken 192 times.
274 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 28)) //28 is 2.50.1 final. Potion bug might have been used, I dunno. -Dimi
2934 {
2935
2/2
✓ Branch 0 taken 139 times.
✓ Branch 1 taken 191 times.
330 set_qr(qr_OLD_POTION_OR_HC, 1);
2936 139 }
2937
2938
4/4
✓ Branch 0 taken 398 times.
✓ Branch 1 taken 67 times.
✓ Branch 2 taken 206 times.
✓ Branch 3 taken 192 times.
331 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<28))
2939 {
2940
2/2
✓ Branch 0 taken 139 times.
✓ Branch 1 taken 134 times.
273 set_qr(qr_OFFSCREENWEAPONS, 1);
2941 139 }
2942
2943 //Bombchu fix.
2944
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 206 times.
331 if(tempheader.zelda_version == 0x250)
2945 {
2946
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 173 times.
206 if ( tempheader.build == 24 ) //2.50.0
2947 {
2948
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 set_qr(qr_BOMBCHUSUPERBOMB, 1);
2949 33 }
2950
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 200 times.
206 if ( tempheader.build == 28 ) //2.50.1
2951 {
2952
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 set_qr(qr_BOMBCHUSUPERBOMB, 1);
2953 6 }
2954
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 124 times.
206 if ( tempheader.build == 29 ) //2.50.2
2955 {
2956
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_BOMBCHUSUPERBOMB, 0);
2957 82 }
2958
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 206 times.
206 if ( tempheader.build == 30 ) //2.50.3RC1
2959 {
2960 set_qr(qr_BOMBCHUSUPERBOMB, 0);
2961 }
2962 206 }
2963
2964
4/4
✓ Branch 0 taken 398 times.
✓ Branch 1 taken 67 times.
✓ Branch 2 taken 206 times.
✓ Branch 3 taken 192 times.
331 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<29))
2965 {
2966 // qr_OFFSETEWPNCOLLISIONFIX
2967 // All 'official' quests need this disabled.
2968 // All 2.10 and lower quests need this enabled to preseve compatability.
2969 // All 2.11 - 2.5.1 quests should have it set also, due to a bug in about half of all the betas.
2970
2971 //~Gleeok
2972
2/2
✓ Branch 0 taken 145 times.
✓ Branch 1 taken 128 times.
273 set_qr(qr_OFFSETEWPNCOLLISIONFIX, 1); //This has to be set!!!!
2973
2974 // Broke in build 695
2975
3/4
✓ Branch 0 taken 63 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 63 times.
✗ Branch 3 not taken.
145 if(tempheader.zelda_version>=0x211 && tempheader.build>=18)
2976
1/2
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
63 set_qr(qr_BROKENSTATUES, 1);
2977 145 }
2978
11/14
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 462 times.
✓ Branch 2 taken 457 times.
✓ Branch 3 taken 5 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 582 times.
✓ Branch 7 taken 5 times.
✓ Branch 8 taken 582 times.
✓ Branch 9 taken 5 times.
✓ Branch 10 taken 22 times.
✓ Branch 11 taken 565 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
337 if (tempheader.zelda_version <= 0x190 || (tempheader.zelda_version == 0x192 && std::string(tempheader.title).starts_with("Zelda 3000\0")))
2979 {
2980
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 set_qr(qr_COPIED_SWIM_SPRITES, 1);
2981 22 }
2982
8/8
✓ Branch 0 taken 206 times.
✓ Branch 1 taken 381 times.
✓ Branch 2 taken 290 times.
✓ Branch 3 taken 91 times.
✓ Branch 4 taken 208 times.
✓ Branch 5 taken 82 times.
✓ Branch 6 taken 192 times.
✓ Branch 7 taken 16 times.
587 if ( (tempheader.zelda_version == 0x250 && tempheader.build < 33) || tempheader.zelda_version == 0x254 || tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x255 && tempheader.build < 50) )
2983 {
2984
2/2
✓ Branch 0 taken 272 times.
✓ Branch 1 taken 299 times.
571 set_qr(qr_OLD_SLASHNEXT_SECRETS, 1);
2985 272 }
2986
2987
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 206 times.
288 if ( (tempheader.zelda_version < 0x211) ) //2.10 water and ladder interaction
2988 {
2989
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_OLD_210_WATER, 1);
2990 82 }
2991
2992
4/6
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 138 times.
✓ Branch 2 taken 192 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 192 times.
288 if ( (tempheader.zelda_version < 0x255 ) || (tempheader.zelda_version == 0x255 && tempheader.build < 51 ) ) //2.10 water and ladder interaction
2993 {
2994
2/2
✓ Branch 0 taken 288 times.
✓ Branch 1 taken 150 times.
138 set_qr(qr_STEP_IS_FLOAT,0);
2995 288 }
2996
2997
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 398 times.
480 if ( tempheader.zelda_version < 0x250 )
2998 {
2999
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_8WAY_SHOT_SFX_DEP, 1);
3000 82 }
3001
3002
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 398 times.
480 if(s_version < 3)
3003 {
3004
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_HOLDNOSTOPMUSIC, 1);
3005
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_CAVEEXITNOSTOPMUSIC, 1);
3006 82 }
3007
3008
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 398 times.
480 if(s_version<4)
3009 {
3010
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(10,0);
3011 82 }
3012
3013
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 398 times.
480 if(s_version<5)
3014 {
3015
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(27,0);
3016 82 }
3017
3018
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 398 times.
480 if(s_version<6)
3019 {
3020
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(46,0);
3021 82 }
3022
3023
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 398 times.
480 if(s_version<7) // January 2008
3024 {
3025
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_HEARTSREQUIREDFIX,0);
3026
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_PUSHBLOCKCSETFIX,1);
3027 82 }
3028
3029
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 398 times.
480 if(s_version<8)
3030 {
3031
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(12, 0);
3032 82 }
3033 else
3034 {
3035
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 set_bit(deprecated_rules, 12, 0);
3036 }
3037
3038
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 398 times.
480 if(s_version<9) // October 2008
3039 {
3040
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_NOROPE2FLASH_DEP,0);
3041
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_NOBUBBLEFLASH_DEP,0);
3042
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_GHINI2BLINK_DEP,0);
3043
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_PHANTOMGHINI2_DEP,0);
3044 82 }
3045
3046
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 398 times.
480 if(s_version<10) // December 2008
3047 {
3048
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_NOCLOCKS_DEP,0);
3049
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_ALLOW10RUPEEDROPS_DEP,0);
3050 82 }
3051
3052
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 398 times.
480 if(s_version<11) // April 2009
3053 {
3054
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_SLOWENEMYANIM_DEP,0);
3055 82 }
3056
3057 // This served no purpose.
3058 // if(s_version<12) // December 2009
3059 // {
3060 // set_qr(qr_BRKBLSHLDS_DEP,0);
3061 // set_qr(qr_OLDTRIBBLES_DEP,0);
3062 // }
3063
3064 //if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 24))
3065
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 398 times.
480 if(s_version < 13)
3066 {
3067
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_SHOPCHEAT, 1);
3068 82 }
3069
3070 // Not entirely sure this is the best place for this...
3071 //2.50.2 bitmap offset fix
3072 480 memset(extra_rules, 0, EXTRARULES_SIZE);
3073
4/4
✓ Branch 0 taken 398 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 206 times.
✓ Branch 3 taken 192 times.
480 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<29))
3074 {
3075
2/2
✓ Branch 0 taken 145 times.
✓ Branch 1 taken 143 times.
288 set_er(er_BITMAPOFFSET, 1);
3076
1/2
✓ Branch 0 taken 145 times.
✗ Branch 1 not taken.
145 set_qr(qr_BITMAPOFFSETFIX, 1);
3077 145 }
3078 //required because quest templates also used this bit, although
3079 //it never did anything, before. -Z
3080
2/2
✓ Branch 0 taken 206 times.
✓ Branch 1 taken 131 times.
337 if ( tempheader.zelda_version == 0x250 )
3081 {
3082
5/6
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 124 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16 times.
✓ Branch 5 taken 108 times.
206 if( tempheader.build == 29 || tempheader.build == 30 || tempheader.build == 31 )
3083 {
3084
1/2
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
98 set_er(er_BITMAPOFFSET, 0);
3085
1/2
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
98 set_qr(qr_BITMAPOFFSETFIX, 0);
3086 98 }
3087 206 }
3088
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 337 times.
337 if ( tempheader.zelda_version == 0x254 )
3089 {
3090 set_er(er_BITMAPOFFSET, 0);
3091 set_qr(qr_BITMAPOFFSETFIX, 0);
3092 }
3093
3/4
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 145 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 192 times.
337 if ( tempheader.zelda_version == 0x255 && tempheader.build < 42 ) //QR was added to 255 in this build.
3094 {
3095 set_er(er_BITMAPOFFSET, 0);
3096 set_qr(qr_BITMAPOFFSETFIX, 0);
3097 }
3098 //optimise fast drawing for older versions.
3099
3/4
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 145 times.
✓ Branch 2 taken 192 times.
✗ Branch 3 not taken.
337 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 42) )
3100 {
3101
2/2
✓ Branch 0 taken 288 times.
✓ Branch 1 taken 97 times.
337 set_qr(qr_OLDSPRITEDRAWS, 1);
3102 288 }
3103 //Old eweapon->Parent (was added in 2.54, Alpha 19)
3104 //The change was made in build 43, but I'm setting this to < 42, because quests made in 42 would benefit from this change, and
3105 //older quests can set the rule by hand. We need a new qst.dat again.
3106
4/4
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 192 times.
✓ Branch 2 taken 192 times.
✓ Branch 3 taken 288 times.
288 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 42) )
3107 {
3108
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 384 times.
384 set_qr(qr_OLDEWPNPARENT, 1);
3109 }
3110
4/4
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 192 times.
✓ Branch 2 taken 192 times.
✓ Branch 3 taken 288 times.
288 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 44) )
3111 {
3112
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 384 times.
384 set_qr(qr_OLDCREATEBITMAP_ARGS, 1);
3113 }
3114
4/4
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 192 times.
✓ Branch 2 taken 192 times.
✓ Branch 3 taken 288 times.
288 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 45) )
3115 {
3116
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 384 times.
384 set_qr(qr_OLDQUESTMISC, 1);
3117 }
3118
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 if ( tempheader.zelda_version < 0x254 )
3119 {
3120
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 set_qr(qr_OLDCREATEBITMAP_ARGS, 0);
3121
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 set_qr(qr_OLDEWPNPARENT, 0);
3122
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 set_qr(qr_OLDQUESTMISC, 0);
3123 288 }
3124
3125 //item scripts continue to run
3126
3/4
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 138 times.
✓ Branch 2 taken 192 times.
✗ Branch 3 not taken.
288 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 44) )
3127 {
3128
2/2
✓ Branch 0 taken 288 times.
✓ Branch 1 taken 42 times.
330 set_qr(qr_ITEMSCRIPTSKEEPRUNNING, 0);
3129
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 set_qr(qr_SCRIPTSRUNINHEROSTEPFORWARD, 0);
3130
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 set_qr(qr_FIXSCRIPTSDURINGSCROLLING, 0);
3131
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 set_qr(qr_SCRIPTDRAWSINWARPS, 0);
3132
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 set_qr(qr_DYINGENEMYESDONTHURTHERO, 0);
3133
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 set_qr(qr_OUTOFBOUNDSENEMIES, 0);
3134
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 set_qr(qr_SPRITEXY_IS_FLOAT, 0);
3135 288 }
3136
3137
3/4
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 138 times.
✓ Branch 2 taken 192 times.
✗ Branch 3 not taken.
288 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 46) )
3138 {
3139
2/2
✓ Branch 0 taken 288 times.
✓ Branch 1 taken 42 times.
330 set_qr(qr_CLEARINITDONSCRIPTCHANGE, 1);
3140 288 }
3141
3/4
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 138 times.
✓ Branch 2 taken 192 times.
✗ Branch 3 not taken.
288 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 46) )
3142 {
3143
2/2
✓ Branch 0 taken 288 times.
✓ Branch 1 taken 42 times.
330 set_qr(qr_TRACESCRIPTIDS, 0);
3144
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 set_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES, 1);
3145
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 set_qr(qr_PARSER_BOOL_TRUE_DECIMAL, 1);
3146
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 set_qr(qr_PARSER_250DIVISION,1);
3147
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 set_qr(qr_PARSER_BOOL_TRUE_DECIMAL,1);
3148
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 set_qr(qr_PARSER_TRUE_INT_SIZE,0);
3149
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 set_qr(qr_PARSER_FORCE_INLINE,0);
3150
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 set_qr(qr_PARSER_BINARY_32BIT,0);
3151
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 279 times.
288 if ( get_qr(qr_SELECTAWPN) )
3152 {
3153
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 set_qr(qr_NO_L_R_BUTTON_INVENTORY_SWAP,1);
3154 //In < 2.55a27, if you had an A+B subscreen, L and R didn't shift through inventory.
3155 //Now they **do**, unless you disable that behaviour.
3156 //For the sake of compatibility, old quests with the A+B subscreen rule enabed
3157 //now enable the disable L/R item swap on load.
3158 9 }
3159
3160 288 }
3161
3/4
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 138 times.
✓ Branch 2 taken 192 times.
✗ Branch 3 not taken.
288 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 47) )
3162 {
3163 //Compatibility: Setting the hero's action to rafting was previously disallowed, though legal for scripts to attempt.
3164
2/2
✓ Branch 0 taken 288 times.
✓ Branch 1 taken 42 times.
330 set_qr(qr_DISALLOW_SETTING_RAFTING, 1);
3165 //Compatibility: The calculation for when to loop an animation did not factor in ASkipY correctly, resulting in
3166 //animations ending earlier than they should.
3167
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 set_qr(qr_BROKEN_ASKIP_Y_FRAMES, 1);
3168 //Enemies would ignore solidity on the top half of combos
3169
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 set_qr(qr_ENEMY_BROKEN_TOP_HALF_SOLIDITY, 1);
3170 //Ceiling collison was a bit wonky, including hitting your head before you are near the ceiling or clipping into it slightly.
3171
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 set_qr(qr_OLD_SIDEVIEW_CEILING_COLLISON, 1);
3172 //If an itemdata had a 'frames' of 0, items created of that data would ignore all changes to 'frames'
3173
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 set_qr(qr_0AFRAME_ITEMS_IGNORE_AFRAME_CHANGES, 1);
3174 //Collision used some odd calculations before, and enemies could not be hit back into the top row or left column
3175
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 set_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION, 1);
3176 288 }
3177
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 if ( tempheader.zelda_version < 0x255 )
3178 {
3179
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 set_qr(qr_NOFFCWAITDRAW, 1);
3180
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 set_qr(qr_NOITEMWAITDRAW, 1);
3181
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 set_qr(qr_SETENEMYWEAPONSPRITESONWPNCHANGE, 1);
3182
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 set_qr(qr_OLD_INIT_SCRIPT_TIMING, 1);
3183 //set_qr(qr_DO_NOT_DEALLOCATE_INIT_AND_SAVELOAD_ARRAYS, 1);
3184 288 }
3185
3/4
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 138 times.
✓ Branch 2 taken 192 times.
✗ Branch 3 not taken.
288 if ( tempheader.zelda_version < 0x255 || ( tempheader.zelda_version == 0x255 && tempheader.build < 48 ) )
3186 {
3187
2/2
✓ Branch 0 taken 288 times.
✓ Branch 1 taken 42 times.
330 set_qr(qr_SETENEMYWEAPONSPRITESONWPNCHANGE, 1);
3188 288 }
3189
3/4
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 138 times.
✓ Branch 2 taken 192 times.
✗ Branch 3 not taken.
288 if( tempheader.zelda_version < 0x255 || ( tempheader.zelda_version == 0x255 && tempheader.build < 52 ) )
3190 {
3191
2/2
✓ Branch 0 taken 288 times.
✓ Branch 1 taken 42 times.
330 set_qr(qr_OLD_PRINTF_ARGS, 1);
3192 288 }
3193
3194
3195
3/4
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 138 times.
✓ Branch 2 taken 192 times.
✗ Branch 3 not taken.
288 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 54) )
3196 {
3197
2/2
✓ Branch 0 taken 288 times.
✓ Branch 1 taken 42 times.
330 set_qr(qr_BROKEN_RING_POWER, 1);
3198 288 }
3199
3/4
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 138 times.
✓ Branch 2 taken 192 times.
✗ Branch 3 not taken.
288 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 56) )
3200 {
3201
2/2
✓ Branch 0 taken 288 times.
✓ Branch 1 taken 42 times.
330 set_qr(qr_NO_OVERWORLD_MAP_CHARTING, 1);
3202 288 }
3203
5/6
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 138 times.
✓ Branch 2 taken 192 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 150 times.
✓ Branch 5 taken 42 times.
288 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 57) )
3204 {
3205
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 set_qr(qr_DUNGEONS_USE_CLASSIC_CHARTING, 1);
3206 288 }
3207
3/4
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 138 times.
✓ Branch 2 taken 192 times.
✗ Branch 3 not taken.
330 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 58) )
3208 {
3209 //Rule used to be 'qr_SETXYBUTTONITEMS', now split.
3210
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 288 times.
330 if(get_qr(qr_SET_XBUTTON_ITEMS))
3211 set_qr(qr_SET_YBUTTON_ITEMS,1);
3212 288 }
3213
3/4
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 138 times.
✓ Branch 2 taken 192 times.
✗ Branch 3 not taken.
288 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 59) )
3214 {
3215
2/2
✓ Branch 0 taken 288 times.
✓ Branch 1 taken 42 times.
330 set_qr(qr_ALLOW_EDITING_COMBO_0,1);
3216 288 }
3217
3/4
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 138 times.
✓ Branch 2 taken 192 times.
✗ Branch 3 not taken.
288 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 60) )
3218 {
3219
2/2
✓ Branch 0 taken 288 times.
✓ Branch 1 taken 42 times.
330 set_qr(qr_OLD_CHEST_COLLISION,1);
3220 288 }
3221
3222
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 if ( tempheader.zelda_version < 0x254 )
3223 {
3224
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 set_qr(qr_250WRITEEDEFSCRIPT, 1);
3225 288 }
3226 //Sideview spikes in 2.50.0
3227
4/4
✓ Branch 0 taken 398 times.
✓ Branch 1 taken 116 times.
✓ Branch 2 taken 206 times.
✓ Branch 3 taken 192 times.
288 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<27)) //2.50.1RC3
3228 {
3229
2/2
✓ Branch 0 taken 139 times.
✓ Branch 1 taken 183 times.
322 set_qr(qr_OLDSIDEVIEWSPIKES, 1);
3230 139 }
3231 //more 2.50 fixes -Z
3232
4/4
✓ Branch 0 taken 398 times.
✓ Branch 1 taken 67 times.
✓ Branch 2 taken 206 times.
✓ Branch 3 taken 192 times.
331 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<31))
3233 {
3234
2/2
✓ Branch 0 taken 227 times.
✓ Branch 1 taken 68 times.
273 set_qr(qr_MELEEMAGICCOST, 0);
3235
1/2
✓ Branch 0 taken 227 times.
✗ Branch 1 not taken.
227 set_qr(qr_GANONINTRO, 0); //This will get flipped later on in the compatrule 11 check. That's why it's turning it off.
3236
1/2
✓ Branch 0 taken 227 times.
✗ Branch 1 not taken.
227 set_qr(qr_OLDMIRRORCOMBOS, 1);
3237
1/2
✓ Branch 0 taken 227 times.
✗ Branch 1 not taken.
227 set_qr(qr_BROKENBOOKCOST, 1);
3238
1/2
✓ Branch 0 taken 227 times.
✗ Branch 1 not taken.
227 set_qr(qr_BROKENCHARINTDRAWING, 1);
3239
3240 227 }
3241
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 419 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
419 if(tempheader.zelda_version == 0x254 && tempheader.build<41)
3242 {
3243 //set_qr(qr_MELEEMAGICCOST, get_er(er_MAGICCOSTSWORD));
3244 set_qr(qr_MELEEMAGICCOST, 1);
3245 }
3246
3247
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 396 times.
419 if(tempheader.zelda_version < 0x193)
3248 {
3249
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_qr(qr_SHORTDGNWALK, 1);
3250 23 }
3251
3252
2/2
✓ Branch 0 taken 288 times.
✓ Branch 1 taken 131 times.
419 if(tempheader.zelda_version < 0x255)
3253 {
3254
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 set_qr(qr_OLDINFMAGIC, 1);
3255 288 }
3256
3257
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 337 times.
419 if((tempheader.zelda_version < 0x250)) //2.10 and earlier allowed the triforce to Warp Hero out of Item Cellars in Dungeons. -Z (15th March, 2019 )
3258 {
3259
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_SIDEVIEWTRIFORCECELLAR,1);
3260 82 }
3261
3262
3/4
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 227 times.
✓ Branch 2 taken 192 times.
✗ Branch 3 not taken.
419 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 47) )
3263 {
3264
2/2
✓ Branch 0 taken 288 times.
✓ Branch 1 taken 131 times.
419 set_qr(qr_OLD_F6,1);
3265 288 }
3266
3/4
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 138 times.
✓ Branch 2 taken 192 times.
✗ Branch 3 not taken.
288 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 49) )
3267 {
3268
2/2
✓ Branch 0 taken 288 times.
✓ Branch 1 taken 42 times.
330 set_qr(qr_NO_OVERWRITING_HOPPING,1);
3269 288 }
3270
3/4
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 138 times.
✓ Branch 2 taken 192 times.
✗ Branch 3 not taken.
288 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 50) )
3271 {
3272
2/2
✓ Branch 0 taken 288 times.
✓ Branch 1 taken 42 times.
330 set_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT,1);
3273 288 }
3274
3/4
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 138 times.
✓ Branch 2 taken 192 times.
✗ Branch 3 not taken.
288 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 53) )
3275 {
3276
2/2
✓ Branch 0 taken 288 times.
✓ Branch 1 taken 42 times.
330 set_qr(qr_BROKEN_OVERWORLD_MINIMAP,1);
3277 288 }
3278 //}
3279
3280
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 if(compatrule_version < 1) //Enemies->Secret only affects flag 16-31
3281
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 set_qr(qr_ENEMIES_SECRET_ONLY_16_31,1);
3282
3283
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 if(compatrule_version < 2) //Old CSet2 Handling
3284
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 set_qr(qr_OLDCS2,1);
3285
3286
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 if(compatrule_version < 3) //Hardcoded Shadow/Spawn/Death anim frames
3287
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 set_qr(qr_HARDCODED_ENEMY_ANIMS,1);
3288
3289
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 if(compatrule_version < 4) //Hardcoded Shadow/Spawn/Death anim frames
3290
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 set_qr(qr_OLD_ITEMDATA_SCRIPT_TIMING,1);
3291
3292
3/4
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 206 times.
✓ Branch 3 taken 82 times.
288 if(compatrule_version < 5 && tempheader.zelda_version >= 0x250) //Hardcoded Shadow/Spawn/Death anim frames
3293
1/2
✓ Branch 0 taken 206 times.
✗ Branch 1 not taken.
206 set_qr(qr_NO_LANMOLA_RINGLEADER,1);
3294
3295
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 if(compatrule_version < 6) //Step->Secret (Temp) only affects flag 16-31
3296
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 set_qr(qr_STEPTEMP_SECRET_ONLY_16_31,1);
3297
3298
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 if(compatrule_version < 7) //'Hit All Triggers->Perm Secret' doesn't trigger temp secrets
3299
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 set_qr(qr_ALLTRIG_PERMSEC_NO_TEMP,1);
3300
3301
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 if(compatrule_version < 8) //Hardcoded LItem/Bomb/Clock/Magic Tile Mods
3302
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 set_qr(qr_HARDCODED_LITEM_LTMS,1);
3303
3304
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 if(compatrule_version < 9)
3305 {
3306 //Hardcoded BS Patras
3307
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 set_qr(qr_HARDCODED_BS_PATRA,1);
3308 //Hardcoded Patra Inner Eye offsets
3309
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 set_qr(qr_PATRAS_USE_HARDCODED_OFFSETS,1);
3310 //Broken 'Big enemy' animation style
3311
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 set_qr(qr_BROKEN_BIG_ENEMY_ANIMATION,1);
3312 //Broken Attribute 31/32
3313
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 set_qr(qr_BROKEN_ATTRIBUTE_31_32,1);
3314 288 }
3315
3316
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 if(compatrule_version < 10) //Shared candle use limits
3317
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 set_qr(qr_CANDLES_SHARED_LIMIT,1);
3318
3319
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 if(compatrule_version < 11) //No cross-screen return points
3320
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 set_qr(qr_OLD_RESPAWN_POINTS,1);
3321
3322
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 if(compatrule_version < 12)
3323 {
3324 //Old fire trail duration
3325
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 set_qr(qr_OLD_FLAMETRAIL_DURATION,1);
3326 //Old Intro String in Ganon Room Behavior
3327
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 288 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
288 if(get_qr(qr_GANONINTRO)) set_qr(qr_GANONINTRO,0);
3328
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 else set_qr(qr_GANONINTRO,1);
3329 288 }
3330
3331
2/4
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 288 times.
288 if(compatrule_version < 13 && tempheader.zelda_version >= 0x255) //ANone doesn't reset to originaltile
3332 set_qr(qr_ANONE_NOANIM,1);
3333
3334
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 if(compatrule_version < 14) //Old Bridge Combo Behavior
3335
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 set_qr(qr_OLD_BRIDGE_COMBOS,1);
3336
3337
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 if(compatrule_version < 15) //Broken Z3 Animation
3338
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 set_qr(qr_BROKEN_Z3_ANIMATION,1);
3339
3340
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 if(compatrule_version < 16) //Old Enemy Tile Behavior with Animation (None) Enemies
3341
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 set_qr(qr_OLD_TILE_INITIALIZATION,1);
3342
3343
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 288 times.
288 if(compatrule_version < 17)
3344 {
3345 //Old Quake/DrawYOffset behavior
3346 //set_qr(qr_OLD_DRAWOFFSET,1);
3347 //I'm leaving this commented cause I doubt it'll break anything and I think the bugfix might be appreciated in older versions.
3348 //On the offchance that it *does* break old quests, fixing it is as simple as uncommenting the set_bit above.
3349 288 }
3350
3351
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 if(compatrule_version < 18)
3352 {
3353 //Broken DrawScreen Derivative Functions
3354
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 set_qr(qr_BROKEN_DRAWSCREEN_FUNCTIONS,1);
3355 //Scrolling Cancels Charge
3356
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 set_qr(qr_SCROLLING_KILLS_CHARGE,1);
3357 288 }
3358
3359
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 if(compatrule_version < 19) //Broken Enemy Item Carrying with Large Enemies
3360
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 set_qr(qr_BROKEN_ITEM_CARRYING,1);
3361
3362
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 if(compatrule_version < 20)
3363
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 set_qr(qr_CUSTOMWEAPON_IGNORE_COST,1);
3364
3365
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 if(compatrule_version < 21)
3366 {
3367
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 set_qr(qr_LEEVERS_DONT_OBEY_STUN,1);
3368
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 set_qr(qr_GANON_CANT_SPAWN_ON_CONTINUE,1);
3369
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 set_qr(qr_WIZZROBES_DONT_OBEY_STUN,1);
3370
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 set_qr(qr_OLD_BUG_NET,1);
3371
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 set_qr(qr_MANHANDLA_BLOCK_SFX,1);
3372 288 }
3373
3374
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 if(compatrule_version < 22)
3375
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 set_qr(qr_BROKEN_KEEPOLD_FLAG,1);
3376
3377
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 if(compatrule_version < 23)
3378
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 set_qr(qr_OLD_HALF_MAGIC,1);
3379
3380
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 if(compatrule_version < 24)
3381 {
3382
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 set_qr(qr_WARPS_RESTART_DMAPSCRIPT,1);
3383
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 set_qr(qr_DMAP_0_CONTINUE_BUG,1);
3384 288 }
3385
3386
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 288 times.
288 if(compatrule_version < 25)
3387 {
3388
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 288 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
288 if (get_qr(qr_OLD_FAIRY_LIMIT)) set_qr(qr_OLD_FAIRY_LIMIT,0);
3389
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 else set_qr(qr_OLD_FAIRY_LIMIT,1);
3390
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 set_qr(qr_OLD_SCRIPTED_KNOCKBACK,1);
3391 288 }
3392
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 if(compatrule_version < 26)
3393 {
3394
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 set_qr(qr_OLD_KEESE_Z_AXIS,1);
3395
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 set_qr(qr_POLVIRE_NO_SHADOW,1);
3396
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 set_qr(qr_SUBSCR_OLD_SELECTOR,1);
3397 288 }
3398
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 288 times.
288 if(compatrule_version < 27) //Noticed some junk data in the QR array...
3399 {
3400
2/2
✓ Branch 0 taken 86688 times.
✓ Branch 1 taken 288 times.
86976 for(auto q = qr_POLVIRE_NO_SHADOW+1; q < qr_PARSER_250DIVISION; ++q)
3401
1/2
✓ Branch 0 taken 86688 times.
✗ Branch 1 not taken.
86688 set_qr(q,0);
3402
2/2
✓ Branch 0 taken 1728 times.
✓ Branch 1 taken 288 times.
2016 for(auto q = qr_COMBODATA_INITD_MULT_TENK+1; q < qr_MAX; ++q)
3403
1/2
✓ Branch 0 taken 1728 times.
✗ Branch 1 not taken.
1728 set_qr(q,0);
3404 //This should nuke any remaining junk data... not sure if it affected anything previous. -Em
3405 288 }
3406
2/2
✓ Branch 0 taken 293 times.
✓ Branch 1 taken 5 times.
288 if(compatrule_version < 28)
3407
1/2
✓ Branch 0 taken 293 times.
✗ Branch 1 not taken.
293 set_qr(qr_SUBSCR_BACKWARDS_ID_ORDER,1);
3408
2/2
✓ Branch 0 taken 293 times.
✓ Branch 1 taken 5 times.
298 if(compatrule_version < 29)
3409
1/2
✓ Branch 0 taken 293 times.
✗ Branch 1 not taken.
293 set_qr(qr_OLD_LOCKBLOCK_COLLISION,1);
3410
2/2
✓ Branch 0 taken 293 times.
✓ Branch 1 taken 5 times.
298 if(compatrule_version < 30)
3411 {
3412
1/2
✓ Branch 0 taken 293 times.
✗ Branch 1 not taken.
293 set_qr(qr_DECO_2_YOFFSET,1);
3413
1/2
✓ Branch 0 taken 293 times.
✗ Branch 1 not taken.
293 set_qr(qr_SCREENSTATE_80s_BUG,1);
3414 293 }
3415
2/2
✓ Branch 0 taken 293 times.
✓ Branch 1 taken 5 times.
298 if(compatrule_version < 31)
3416 {
3417
1/2
✓ Branch 0 taken 293 times.
✗ Branch 1 not taken.
293 set_qr(qr_GOHMA_UNDAMAGED_BUG,1);
3418
1/2
✓ Branch 0 taken 293 times.
✗ Branch 1 not taken.
293 set_qr(qr_FFCPRELOAD_BUGGED_LOAD,1);
3419 293 }
3420
2/2
✓ Branch 0 taken 293 times.
✓ Branch 1 taken 5 times.
298 if(compatrule_version < 32)
3421
1/2
✓ Branch 0 taken 293 times.
✗ Branch 1 not taken.
293 set_qr(qr_BROKEN_GETPIXEL_VALUE,1);
3422
2/2
✓ Branch 0 taken 293 times.
✓ Branch 1 taken 5 times.
298 if(compatrule_version < 33)
3423
1/2
✓ Branch 0 taken 293 times.
✗ Branch 1 not taken.
293 set_qr(qr_NO_LIFT_SPRITE,1);
3424
2/2
✓ Branch 0 taken 293 times.
✓ Branch 1 taken 5 times.
298 if(compatrule_version < 34)
3425 {
3426
1/2
✓ Branch 0 taken 293 times.
✗ Branch 1 not taken.
293 set_qr(qr_OLD_SIDEVIEW_LANDING_CODE,1);
3427
1/2
✓ Branch 0 taken 293 times.
✗ Branch 1 not taken.
293 set_qr(qr_OLD_FFC_SPEED_CAP,1);
3428
1/2
✓ Branch 0 taken 293 times.
✗ Branch 1 not taken.
293 set_qr(qr_OLD_FFC_FUNCTIONALITY,1);
3429
1/2
✓ Branch 0 taken 293 times.
✗ Branch 1 not taken.
293 set_qr(qr_OLD_WIZZROBE_SUBMERGING,1);
3430 293 }
3431
2/2
✓ Branch 0 taken 295 times.
✓ Branch 1 taken 3 times.
298 if(compatrule_version < 35)
3432 {
3433
1/2
✓ Branch 0 taken 295 times.
✗ Branch 1 not taken.
295 set_qr(qr_ZS_NO_NEG_ARRAY,1);
3434
1/2
✓ Branch 0 taken 295 times.
✗ Branch 1 not taken.
295 set_qr(qr_BROKEN_INPUT_DOWN_STATE,1);
3435 295 }
3436
2/2
✓ Branch 0 taken 295 times.
✓ Branch 1 taken 3 times.
298 if(compatrule_version < 36)
3437
1/2
✓ Branch 0 taken 295 times.
✗ Branch 1 not taken.
295 set_qr(qr_OLD_SHALLOW_SFX,1);
3438
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 3 times.
298 if(compatrule_version < 37)
3439
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_SPARKLES_INHERIT_PROPERTIES,1);
3440
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 3 times.
302 if(compatrule_version < 38)
3441
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_BUGGED_LAYERED_FLAGS,1);
3442
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 3 times.
302 if(compatrule_version < 39)
3443
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_HARDCODED_FFC_BUSH_DROPS,1);
3444
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 3 times.
302 if(compatrule_version < 40)
3445
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_MOVINGBLOCK_FAKE_SOLID,1);
3446
2/2
✓ Branch 0 taken 301 times.
✓ Branch 1 taken 5 times.
302 if(compatrule_version < 41)
3447
1/2
✓ Branch 0 taken 301 times.
✗ Branch 1 not taken.
301 set_qr(qr_BROKENHITBY,1);
3448
2/2
✓ Branch 0 taken 301 times.
✓ Branch 1 taken 5 times.
306 if(compatrule_version < 42)
3449
1/2
✓ Branch 0 taken 301 times.
✗ Branch 1 not taken.
301 set_qr(qr_BROKEN_MOVING_BOMBS,1);
3450
2/2
✓ Branch 0 taken 301 times.
✓ Branch 1 taken 5 times.
306 if(compatrule_version < 43)
3451
1/2
✓ Branch 0 taken 301 times.
✗ Branch 1 not taken.
301 set_qr(qr_OLD_BOMB_HITBOXES,1);
3452
2/2
✓ Branch 0 taken 301 times.
✓ Branch 1 taken 5 times.
306 if(compatrule_version < 44)
3453
1/2
✓ Branch 0 taken 301 times.
✗ Branch 1 not taken.
301 set_qr(qr_SCROLLWARP_NO_RESET_FRAME,1);
3454
2/2
✓ Branch 0 taken 301 times.
✓ Branch 1 taken 5 times.
306 if(compatrule_version < 45)
3455
1/2
✓ Branch 0 taken 301 times.
✗ Branch 1 not taken.
301 set_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME,1);
3456
2/2
✓ Branch 0 taken 301 times.
✓ Branch 1 taken 5 times.
306 if(compatrule_version < 46)
3457
1/2
✓ Branch 0 taken 301 times.
✗ Branch 1 not taken.
301 set_qr(qr_BROKEN_RAFT_SCROLL,1);
3458
2/2
✓ Branch 0 taken 305 times.
✓ Branch 1 taken 7 times.
306 if(compatrule_version < 47)
3459 {
3460
1/2
✓ Branch 0 taken 305 times.
✗ Branch 1 not taken.
305 set_qr(qr_SENSITIVE_SOLID_DAMAGE,1);
3461
1/2
✓ Branch 0 taken 305 times.
✗ Branch 1 not taken.
305 set_qr(qr_OLD_CONVEYOR_COLLISION,1);
3462 305 }
3463
2/2
✓ Branch 0 taken 305 times.
✓ Branch 1 taken 7 times.
312 if(compatrule_version < 48)
3464
1/2
✓ Branch 0 taken 305 times.
✗ Branch 1 not taken.
305 set_qr(qr_OLD_GUY_HANDLING,1);
3465
2/2
✓ Branch 0 taken 305 times.
✓ Branch 1 taken 7 times.
312 if(compatrule_version < 49)
3466
1/2
✓ Branch 0 taken 305 times.
✗ Branch 1 not taken.
305 set_qr(qr_FAIRY_FLAG_COMPAT,1);
3467
2/2
✓ Branch 0 taken 305 times.
✓ Branch 1 taken 7 times.
312 if(compatrule_version < 50)
3468
1/2
✓ Branch 0 taken 305 times.
✗ Branch 1 not taken.
305 set_qr(qr_OLD_LENS_LAYEREFFECT,1);
3469
2/2
✓ Branch 0 taken 305 times.
✓ Branch 1 taken 7 times.
312 if(compatrule_version < 51)
3470
1/2
✓ Branch 0 taken 305 times.
✗ Branch 1 not taken.
305 set_qr(qr_PUSHBLOCK_SPRITE_LAYER,1);
3471
2/2
✓ Branch 0 taken 305 times.
✓ Branch 1 taken 7 times.
312 if (compatrule_version < 52)
3472
1/2
✓ Branch 0 taken 305 times.
✗ Branch 1 not taken.
305 set_qr(qr_OLD_SCRIPT_VOLUME, 1);
3473
2/2
✓ Branch 0 taken 305 times.
✓ Branch 1 taken 7 times.
312 if(compatrule_version < 53)
3474 {
3475
1/2
✓ Branch 0 taken 305 times.
✗ Branch 1 not taken.
305 set_qr(qr_OLD_SUBSCR,1);
3476
1/2
✓ Branch 0 taken 305 times.
✗ Branch 1 not taken.
305 set_qr(qr_ITM_0_INVIS_ON_BTNS,1);
3477
1/2
✓ Branch 0 taken 305 times.
✗ Branch 1 not taken.
305 set_qr(qr_OLD_GAUGE_TILE_LAYOUT,1);
3478 305 }
3479
2/2
✓ Branch 0 taken 305 times.
✓ Branch 1 taken 7 times.
312 if(compatrule_version < 54)
3480
1/2
✓ Branch 0 taken 305 times.
✗ Branch 1 not taken.
305 set_qr(qr_WALKTHROUGHWALL_NO_DOORSTATE,1);
3481
2/2
✓ Branch 0 taken 305 times.
✓ Branch 1 taken 7 times.
312 if(compatrule_version < 55)
3482
1/2
✓ Branch 0 taken 305 times.
✗ Branch 1 not taken.
305 set_qr(qr_SPOTLIGHT_IGNR_SOLIDOBJ,1);
3483
2/2
✓ Branch 0 taken 305 times.
✓ Branch 1 taken 7 times.
312 if(compatrule_version < 56)
3484
1/2
✓ Branch 0 taken 305 times.
✗ Branch 1 not taken.
305 set_qr(qr_BROKEN_LIGHTBEAM_HITBOX,1);
3485
2/2
✓ Branch 0 taken 305 times.
✓ Branch 1 taken 7 times.
312 if(compatrule_version < 57)
3486
1/2
✓ Branch 0 taken 305 times.
✗ Branch 1 not taken.
305 set_qr(qr_BROKEN_SWORD_SPIN_TRIGGERS,1);
3487
2/2
✓ Branch 0 taken 305 times.
✓ Branch 1 taken 7 times.
312 if(compatrule_version < 58)
3488
1/2
✓ Branch 0 taken 305 times.
✗ Branch 1 not taken.
305 set_qr(qr_OLD_DMAP_INTRO_STRINGS,1);
3489
2/2
✓ Branch 0 taken 305 times.
✓ Branch 1 taken 7 times.
312 if(compatrule_version < 59)
3490
1/2
✓ Branch 0 taken 305 times.
✗ Branch 1 not taken.
305 set_qr(qr_SCRIPT_CONTHP_IS_HEARTS,1);
3491
2/2
✓ Branch 0 taken 305 times.
✓ Branch 1 taken 7 times.
312 if(compatrule_version < 60)
3492
1/2
✓ Branch 0 taken 305 times.
✗ Branch 1 not taken.
305 set_qr(qr_SEPARATE_BOMBABLE_TAPPING_SFX,1);
3493
2/2
✓ Branch 0 taken 305 times.
✓ Branch 1 taken 7 times.
312 if(compatrule_version < 61)
3494
1/2
✓ Branch 0 taken 305 times.
✗ Branch 1 not taken.
305 set_qr(qr_BROKEN_BOMB_AMMO_COSTS,1);
3495
2/2
✓ Branch 0 taken 305 times.
✓ Branch 1 taken 7 times.
312 if(compatrule_version < 62)
3496
1/2
✓ Branch 0 taken 305 times.
✗ Branch 1 not taken.
305 set_qr(qr_OLD_BROKEN_WARPEX_MUSIC,1);
3497
2/2
✓ Branch 0 taken 306 times.
✓ Branch 1 taken 6 times.
312 if(compatrule_version < 63)
3498 {
3499
1/2
✓ Branch 0 taken 306 times.
✗ Branch 1 not taken.
306 set_qr(qr_BROKEN_LIFTSWIM,1);
3500
1/2
✓ Branch 0 taken 306 times.
✗ Branch 1 not taken.
306 set_qr(qr_BROKEN_GENERIC_PUSHBLOCK_LOCKING,1);
3501 306 }
3502
2/2
✓ Branch 0 taken 306 times.
✓ Branch 1 taken 6 times.
312 if(compatrule_version < 64)
3503
1/2
✓ Branch 0 taken 306 times.
✗ Branch 1 not taken.
306 set_qr(qr_BROKEN_FLAME_ARROW_REFLECTING,1);
3504
2/2
✓ Branch 0 taken 331 times.
✓ Branch 1 taken 21 times.
312 if(compatrule_version < 65)
3505
1/2
✓ Branch 0 taken 331 times.
✗ Branch 1 not taken.
331 set_qr(qr_BROKEN_SIDEVIEW_SPRITE_JUMP,1);
3506
2/2
✓ Branch 0 taken 333 times.
✓ Branch 1 taken 19 times.
352 if(compatrule_version < 66)
3507
1/2
✓ Branch 0 taken 333 times.
✗ Branch 1 not taken.
333 set_qr(qr_NEWDARK_TRANS_STACKING,1);
3508
2/2
✓ Branch 0 taken 333 times.
✓ Branch 1 taken 19 times.
352 if(compatrule_version < 67)
3509
1/2
✓ Branch 0 taken 333 times.
✗ Branch 1 not taken.
333 set_qr(qr_OLD_HERO_WARP_RETSQUARE,1);
3510
2/2
✓ Branch 0 taken 333 times.
✓ Branch 1 taken 19 times.
352 if(compatrule_version < 68)
3511
1/2
✓ Branch 0 taken 333 times.
✗ Branch 1 not taken.
333 set_qr(qr_SCRIPTS_6_BIT_COLOR,1);
3512
2/2
✓ Branch 0 taken 333 times.
✓ Branch 1 taken 19 times.
352 if(compatrule_version < 69)
3513
1/2
✓ Branch 0 taken 333 times.
✗ Branch 1 not taken.
333 set_qr(qr_SETENEMYWEAPONSOUNDSONWPNCHANGE, 1);
3514
2/2
✓ Branch 0 taken 333 times.
✓ Branch 1 taken 19 times.
352 if (compatrule_version < 70)
3515
1/2
✓ Branch 0 taken 333 times.
✗ Branch 1 not taken.
333 set_qr(qr_BROKEN_CONVEYORS, 1);
3516
2/2
✓ Branch 0 taken 333 times.
✓ Branch 1 taken 19 times.
352 if (compatrule_version < 71)
3517
1/2
✓ Branch 0 taken 333 times.
✗ Branch 1 not taken.
333 set_qr(qr_BROKEN_PUSHBLOCK_TOP_HALF_SOLIDS, 1);
3518
2/2
✓ Branch 0 taken 333 times.
✓ Branch 1 taken 19 times.
352 if (compatrule_version < 72)
3519
1/2
✓ Branch 0 taken 333 times.
✗ Branch 1 not taken.
333 set_qr(qr_BROKEN_PUSHBLOCK_FLAG_CLONING, 1);
3520
2/2
✓ Branch 0 taken 333 times.
✓ Branch 1 taken 19 times.
352 if (compatrule_version < 73)
3521 {
3522
1/2
✓ Branch 0 taken 333 times.
✗ Branch 1 not taken.
333 set_qr(qr_OLD_LANDING_SFX, 1);
3523
1/2
✓ Branch 0 taken 333 times.
✗ Branch 1 not taken.
333 set_qr(qr_FIRE_LEVEL_TRIGGERS_ARENT_WEAPONS, 1);
3524 333 }
3525
5/6
✓ Branch 0 taken 333 times.
✓ Branch 1 taken 19 times.
✓ Branch 2 taken 332 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 332 times.
✗ Branch 5 not taken.
352 if (compatrule_version < 74 && (tempheader.version_major >= 3 || tempheader.compareVer(2, 55, 9) < 0))
3526
2/2
✓ Branch 0 taken 333 times.
✓ Branch 1 taken 332 times.
1 set_qr(qr_BROKEN_SCRIPTS_SCROLLING_HERO_POSITION, 1);
3527
5/6
✓ Branch 0 taken 333 times.
✓ Branch 1 taken 351 times.
✓ Branch 2 taken 332 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 332 times.
✗ Branch 5 not taken.
684 if (compatrule_version < 75 && (tempheader.version_major >= 3 || tempheader.compareVer(2, 55, 10) < 0))
3528
2/2
✓ Branch 0 taken 333 times.
✓ Branch 1 taken 332 times.
1 set_qr(qr_BROKEN_SCRIPTS_BITMAP_DRAW_ORIGIN, 1);
3529
5/6
✓ Branch 0 taken 333 times.
✓ Branch 1 taken 683 times.
✓ Branch 2 taken 332 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 332 times.
✗ Branch 5 not taken.
1016 if (compatrule_version < 76 && (tempheader.version_major >= 3 || tempheader.compareVer(2, 55, 10) < 0))
3530
2/2
✓ Branch 0 taken 333 times.
✓ Branch 1 taken 332 times.
1 set_qr(qr_INVERTED_DARK_COMBO_TRIGGERS, 1);
3531
2/2
✓ Branch 0 taken 351 times.
✓ Branch 1 taken 997 times.
1348 if (compatrule_version < 77)
3532
1/2
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
351 set_qr(qr_BROKEN_ICY_FLOOR_SIDEVIEW, 1);
3533
2/2
✓ Branch 0 taken 351 times.
✓ Branch 1 taken 997 times.
1348 if (compatrule_version < 78)
3534
1/2
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
351 set_qr(qr_SCRIPTS_SCREEN_DRAW_LIGHT_NO_OFFSET, 1);
3535
2/2
✓ Branch 0 taken 351 times.
✓ Branch 1 taken 997 times.
1348 if (compatrule_version < 79)
3536
1/2
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
351 set_qr(qr_BROKEN_SYSTEM_COLORS, 1);
3537
2/2
✓ Branch 0 taken 352 times.
✓ Branch 1 taken 996 times.
1348 if (compatrule_version < 80)
3538
1/2
✓ Branch 0 taken 352 times.
✗ Branch 1 not taken.
352 set_qr(qr_ZS_OLD_SUSPEND_FFC, 1);
3539
5/6
✓ Branch 0 taken 358 times.
✓ Branch 1 taken 990 times.
✓ Branch 2 taken 332 times.
✓ Branch 3 taken 26 times.
✓ Branch 4 taken 332 times.
✗ Branch 5 not taken.
1348 if (compatrule_version < 81 && (tempheader.version_major >= 3 || tempheader.compareVer(2, 55, 10) < 0))
3540
2/2
✓ Branch 0 taken 358 times.
✓ Branch 1 taken 332 times.
26 set_qr(qr_BROKEN_SCROLL_INSTEAD_OF_DROWN_FALL, 1);
3541
5/6
✓ Branch 0 taken 358 times.
✓ Branch 1 taken 1322 times.
✓ Branch 2 taken 332 times.
✓ Branch 3 taken 26 times.
✓ Branch 4 taken 332 times.
✗ Branch 5 not taken.
1680 if (compatrule_version < 81 && (tempheader.version_major >= 3 || tempheader.compareVer(2, 55, 6) < 0))
3542
2/2
✓ Branch 0 taken 358 times.
✓ Branch 1 taken 332 times.
26 set_qr(qr_ROPE_ENEMIES_SPEED_NOT_CONFIGURABLE, 1);
3543
2/2
✓ Branch 0 taken 358 times.
✓ Branch 1 taken 1654 times.
2012 if (compatrule_version < 82)
3544 {
3545
1/2
✓ Branch 0 taken 358 times.
✗ Branch 1 not taken.
358 set_qr(qr_EW_ROCKS_HARDCODED_BREAK_ON_SOLID, 1);
3546
1/2
✓ Branch 0 taken 358 times.
✗ Branch 1 not taken.
358 set_qr(qr_IMPRECISE_WEAPON_SOLIDITY_CHECKS, 1);
3547 358 }
3548
5/6
✓ Branch 0 taken 358 times.
✓ Branch 1 taken 1654 times.
✓ Branch 2 taken 332 times.
✓ Branch 3 taken 26 times.
✓ Branch 4 taken 332 times.
✗ Branch 5 not taken.
2012 if (compatrule_version < 83 && (tempheader.version_major >= 3 || tempheader.compareVer(2, 55, 11) < 0))
3549
2/2
✓ Branch 0 taken 358 times.
✓ Branch 1 taken 332 times.
26 set_qr(qr_BROKEN_BLOCKHOLE_PITFALLS, 1);
3550
5/6
✓ Branch 0 taken 408 times.
✓ Branch 1 taken 1936 times.
✓ Branch 2 taken 332 times.
✓ Branch 3 taken 76 times.
✓ Branch 4 taken 332 times.
✗ Branch 5 not taken.
2344 if (compatrule_version < 84 && (tempheader.version_major >= 3 || tempheader.compareVer(2, 55, 11) < 0))
3551
2/2
✓ Branch 0 taken 408 times.
✓ Branch 1 taken 332 times.
76 set_qr(qr_CUSTOM_WEAPON_BROKEN_SIZE, 1);
3552
3553
2/2
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 2196 times.
2676 set_qr(qr_ANIMATECUSTOMWEAPONS,0);
3554
2/2
✓ Branch 0 taken 288 times.
✓ Branch 1 taken 192 times.
480 if (s_version < 16)
3555
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 set_qr(qr_BROKEN_HORIZONTAL_WEAPON_ANIM,1);
3556
3557
1/2
✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
480 *Header = tempheader;
3558
3559 480 return 0;
3560 18208 }
3561
3562 4073610 void init_msgstr(MsgStr *str)
3563 {
3564
2/4
✓ Branch 0 taken 4073610 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4073610 times.
4073610 str->setFromLegacyEncoding("");
3565 4073610 str->nextstring=0;
3566 4073610 str->tile=0;
3567 4073610 str->cset=0;
3568 4073610 str->trans=false;
3569 4073610 str->font=font_zfont;
3570 4073610 str->y=32;
3571 4073610 str->sfx=18;
3572 4073610 str->listpos=0;
3573 4073610 str->x=24;
3574 4073610 str->w=get_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT)!=0 ? 24*8 : 26*8;
3575 4073610 str->h=get_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT)!=0 ? 3*8 : 5*8;
3576 4073610 str->hspace=0;
3577 4073610 str->vspace=0;
3578 4073610 str->stringflags=0;
3579 4073610 str->margins[up] = 8;
3580 4073610 str->margins[down] = 0;
3581 4073610 str->margins[left] = 8;
3582 4073610 str->margins[right] = 8;
3583 4073610 str->portrait_tile = 0;
3584 4073610 str->portrait_cset = 0;
3585 4073610 str->portrait_x = 0;
3586 4073610 str->portrait_y = 0;
3587 4073610 str->portrait_tw = 1;
3588 4073610 str->portrait_th = 1;
3589 4073610 str->shadow_type = 0;
3590 4073610 str->shadow_color = 0;
3591 4073610 str->drawlayer = 6;
3592 4073610 }
3593
3594 480 void init_msgstrings(int32_t start, int32_t end)
3595 {
3596
2/4
✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 480 times.
480 if(end <= start || end-start > msg_strings_size)
3597 return;
3598
3599
2/2
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 3932160 times.
3932640 for(int32_t i=start; i<end; i++)
3600 {
3601 3932160 init_msgstr(&MsgStrings[i]);
3602 3932160 MsgStrings[i].listpos=i;
3603 3932160 }
3604
3605
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 480 times.
480 if(start==0)
3606 {
3607
2/4
✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 480 times.
480 MsgStrings[0].setFromLegacyEncoding("(None)");
3608 480 MsgStrings[0].listpos = 0;
3609 480 }
3610 480 }
3611
3612 481 int32_t readstrings(PACKFILE *f, zquestheader *Header)
3613 {
3614
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 457 times.
481 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_strings);
3615
3616 481 MsgStr tempMsgString;
3617
1/2
✓ Branch 0 taken 481 times.
✗ Branch 1 not taken.
481 init_msgstr(&tempMsgString);
3618
3619 481 word temp_msg_count=0;
3620 word temp_expansion[16];
3621 481 memset(temp_expansion, 0, 16*sizeof(word));
3622 481 char buf[8193] = {0};
3623
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 457 times.
481 if(Header->zelda_version < 0x193)
3624 {
3625 byte tempbyte;
3626 24 int32_t strings_to_read=0;
3627
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 1 times.
24 if (!should_skip)
3628
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_qr(qr_OLD_STRING_EDITOR_MARGINS,true);
3629
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
30 if((Header->zelda_version < 0x192)||
3630
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((Header->zelda_version == 0x192)&&(Header->build<31)))
3631 {
3632 18 strings_to_read=128;
3633 18 temp_msg_count=Header->old_str_count;
3634
3635 // Some sort of string count corruption seems to be common in old quests
3636
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(temp_msg_count>128)
3637 {
3638 temp_msg_count=128;
3639 }
3640 18 }
3641
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 else if((Header->zelda_version == 0x192)&&(Header->build<140))
3642 {
3643 strings_to_read=255;
3644 temp_msg_count=Header->old_str_count;
3645 }
3646 else
3647 {
3648
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!p_igetw(&temp_msg_count,f))
3649 {
3650 return qe_invalid;
3651 }
3652
3653 6 strings_to_read=temp_msg_count;
3654
3655
3/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
6 if (!should_skip && temp_msg_count >= msg_strings_size)
3656 {
3657 Z_message("Reallocating string buffer...\n");
3658
3659 // if((MsgStrings=(MsgStr*)_al_sane_realloc(MsgStrings,sizeof(MsgStr)*MAXMSGS))==NULL)
3660 // return qe_nomem;
3661
3662 //memset(MsgStrings, 0, sizeof(MsgStr)*MAXMSGS);
3663 delete[] MsgStrings;
3664 MsgStrings = new MsgStr[MAXMSGS];
3665 msg_strings_size = MAXMSGS;
3666 for(auto q = 0; q < msg_strings_size; ++q)
3667 {
3668 MsgStrings[q].clear();
3669 }
3670 }
3671 }
3672
3673 //reset the message strings
3674
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 1 times.
24 if (!should_skip)
3675
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 init_msgstrings(0,msg_strings_size);
3676
3677
2/2
✓ Branch 0 taken 2550 times.
✓ Branch 1 taken 24 times.
2574 for(int32_t x=0; x<strings_to_read; x++)
3678 {
3679
1/2
✓ Branch 0 taken 2550 times.
✗ Branch 1 not taken.
2550 init_msgstr(&tempMsgString);
3680 2550 tempMsgString.listpos = x;
3681
3682
2/4
✓ Branch 0 taken 2550 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2550 times.
✗ Branch 3 not taken.
2550 if(!pfread(buf,73,f))
3683 {
3684 return qe_invalid;
3685 }
3686
3687 2550 buf[74] = '\0';
3688
2/4
✓ Branch 0 taken 2550 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2550 times.
✗ Branch 3 not taken.
2550 tempMsgString.setFromLegacyEncoding(buf);
3689
3690
2/4
✓ Branch 0 taken 2550 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2550 times.
✗ Branch 3 not taken.
2550 if(!p_getc(&tempbyte,f))
3691 {
3692 return qe_invalid;
3693 }
3694
3695
3/4
✓ Branch 0 taken 246 times.
✓ Branch 1 taken 2304 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 246 times.
2796 if((Header->zelda_version < 0x192)||
3696
1/2
✓ Branch 0 taken 246 times.
✗ Branch 1 not taken.
246 ((Header->zelda_version == 0x192)&&(Header->build<148)))
3697 {
3698
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2304 times.
2304 tempMsgString.nextstring=tempbyte?x+1:0;
3699
3700
2/4
✓ Branch 0 taken 2304 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2304 times.
✗ Branch 3 not taken.
2304 if(!p_getc(&tempbyte,f))
3701 {
3702 return qe_invalid;
3703 }
3704
3705
2/4
✓ Branch 0 taken 2304 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2304 times.
✗ Branch 3 not taken.
2304 if(!p_getc(&tempbyte,f))
3706 {
3707 return qe_invalid;
3708 }
3709 2304 }
3710 else
3711 {
3712
2/4
✓ Branch 0 taken 246 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 246 times.
✗ Branch 3 not taken.
246 if(!p_igetw(&tempMsgString.nextstring,f))
3713 {
3714 return qe_invalid;
3715 }
3716
3717
2/4
✓ Branch 0 taken 246 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 246 times.
✗ Branch 3 not taken.
246 if(!pfread(temp_expansion,32,f))
3718 {
3719 return qe_invalid;
3720 }
3721 }
3722
3723
2/2
✓ Branch 0 taken 2549 times.
✓ Branch 1 taken 1 times.
2550 if (!should_skip)
3724 {
3725
1/2
✓ Branch 0 taken 2549 times.
✗ Branch 1 not taken.
2549 MsgStrings[x] = tempMsgString;
3726 2549 }
3727 2550 }
3728 24 }
3729 else
3730 {
3731 int32_t dummy_int;
3732 word s_version;
3733
3734 //section version info
3735
2/4
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 457 times.
✗ Branch 3 not taken.
457 if(!p_igetw(&s_version,f))
3736 {
3737 return qe_invalid;
3738 }
3739
3740 457 FFCore.quest_format[vStrings] = s_version;
3741
3742
2/4
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 457 times.
✗ Branch 3 not taken.
457 if(!read_deprecated_section_cversion(f))
3743 {
3744 return qe_invalid;
3745 }
3746
3747 //section size
3748
2/4
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 457 times.
✗ Branch 3 not taken.
457 if(!p_igetl(&dummy_int,f))
3749 {
3750 return qe_invalid;
3751 }
3752
3753 //finally... section data
3754
2/4
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 457 times.
✗ Branch 3 not taken.
457 if(!p_igetw(&temp_msg_count,f))
3755 {
3756 return qe_invalid;
3757 }
3758
3759
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
457 if(temp_msg_count >= msg_strings_size && !should_skip)
3760 {
3761 Z_message("Reallocating string buffer...\n");
3762
3763 delete[] MsgStrings;
3764 MsgStrings = new MsgStr[MAXMSGS];
3765 msg_strings_size = MAXMSGS;
3766 for(auto q = 0; q < msg_strings_size; ++q)
3767 {
3768 MsgStrings[q].clear();
3769 }
3770 }
3771
3772 //reset the message strings
3773
2/2
✓ Branch 0 taken 265 times.
✓ Branch 1 taken 192 times.
457 if(s_version < 7)
3774
1/2
✓ Branch 0 taken 265 times.
✗ Branch 1 not taken.
265 set_qr(qr_OLD_STRING_EDITOR_MARGINS,true);
3775
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 if (!should_skip)
3776
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 init_msgstrings(0,msg_strings_size);
3777
3778 457 int32_t string_length=(s_version<2)?73:145;
3779
3780
2/2
✓ Branch 0 taken 138419 times.
✓ Branch 1 taken 457 times.
138876 for(int32_t i=0; i<temp_msg_count; i++)
3781 {
3782
1/2
✓ Branch 0 taken 138419 times.
✗ Branch 1 not taken.
138419 init_msgstr(&tempMsgString);
3783 138419 tempMsgString.listpos = i;
3784
2/2
✓ Branch 0 taken 5844 times.
✓ Branch 1 taken 132575 times.
138419 if(s_version > 8)
3785 {
3786
2/4
✓ Branch 0 taken 5844 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5844 times.
✗ Branch 3 not taken.
5844 if(!p_igetl(&string_length,f))
3787 {
3788 return qe_invalid;
3789 }
3790 5844 }
3791
3792
2/4
✓ Branch 0 taken 138419 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 138419 times.
138419 if (string_length < 0 || string_length > 8193)
3793 {
3794 return qe_invalid;
3795 }
3796
3797
2/2
✓ Branch 0 taken 137867 times.
✓ Branch 1 taken 552 times.
138419 if (string_length > 0)
3798 {
3799
2/4
✓ Branch 0 taken 137867 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 137867 times.
✗ Branch 3 not taken.
137867 if (!pfread(buf, string_length, f))
3800 {
3801 return qe_invalid;
3802 }
3803 137867 }
3804 else
3805 {
3806 552 buf[0] = 0;
3807 }
3808
3809
2/4
✓ Branch 0 taken 138419 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 138419 times.
✗ Branch 3 not taken.
138419 if(!p_igetw(&tempMsgString.nextstring,f))
3810 {
3811 return qe_invalid;
3812 }
3813
3814
2/2
✓ Branch 0 taken 33613 times.
✓ Branch 1 taken 104806 times.
138419 if(s_version<2)
3815 {
3816 33613 buf[72] = '\0';
3817
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 33613 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 33613 times.
33613 tempMsgString.setFromLegacyEncoding(buf);
3818 33613 }
3819 else
3820 {
3821 // June 2008: A bug corrupted the last 4 chars of a string.
3822 // Discard these.
3823
1/2
✓ Branch 0 taken 104806 times.
✗ Branch 1 not taken.
104806 if(s_version<3)
3824 {
3825 for(int32_t j=140; j<144; j++)
3826 {
3827 buf[j] = '\0';
3828 }
3829 }
3830
1/2
✓ Branch 0 taken 104806 times.
✗ Branch 1 not taken.
104806 if(string_length > 8192) string_length = 8192;
3831 104806 buf[string_length]='\0'; //Force-terminate
3832
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 104806 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 104806 times.
104806 tempMsgString.setFromLegacyEncoding(buf);
3833
3834
2/2
✓ Branch 0 taken 5844 times.
✓ Branch 1 taken 98962 times.
104806 if ( s_version >= 6 )
3835 {
3836
2/4
✓ Branch 0 taken 5844 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5844 times.
✗ Branch 3 not taken.
5844 if(!p_igetl(&tempMsgString.tile,f))
3837 {
3838 return qe_invalid;
3839 }
3840 5844 }
3841 else
3842 {
3843
2/4
✓ Branch 0 taken 98962 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98962 times.
✗ Branch 3 not taken.
98962 if(!p_igetw(&tempMsgString.tile,f))
3844 {
3845 return qe_invalid;
3846 }
3847 }
3848
3849
2/4
✓ Branch 0 taken 104806 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104806 times.
✗ Branch 3 not taken.
104806 if(!p_getc(&tempMsgString.cset,f))
3850 {
3851 return qe_invalid;
3852 }
3853
3854 byte dummy_char;
3855
3856
2/4
✓ Branch 0 taken 104806 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104806 times.
✗ Branch 3 not taken.
104806 if(!p_getc(&dummy_char,f)) // trans is stored as a char...
3857 {
3858 return qe_invalid;
3859 }
3860
3861 104806 tempMsgString.trans=dummy_char!=0;
3862
3863
2/4
✓ Branch 0 taken 104806 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104806 times.
✗ Branch 3 not taken.
104806 if(!p_getc(&tempMsgString.font,f))
3864 {
3865 return qe_invalid;
3866 }
3867
3868
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104806 times.
104806 if(s_version < 5)
3869 {
3870 if(!p_getc(&tempMsgString.y,f))
3871 {
3872 return qe_invalid;
3873 }
3874 }
3875 else
3876 {
3877
2/4
✓ Branch 0 taken 104806 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104806 times.
✗ Branch 3 not taken.
104806 if(!p_igetw(&tempMsgString.x,f))
3878 {
3879 return qe_invalid;
3880 }
3881
3882
2/4
✓ Branch 0 taken 104806 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104806 times.
✗ Branch 3 not taken.
104806 if(!p_igetw(&tempMsgString.y,f))
3883 {
3884 return qe_invalid;
3885 }
3886
3887
2/4
✓ Branch 0 taken 104806 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104806 times.
✗ Branch 3 not taken.
104806 if(!p_igetw(&tempMsgString.w,f))
3888 {
3889 return qe_invalid;
3890 }
3891
3892
2/4
✓ Branch 0 taken 104806 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104806 times.
✗ Branch 3 not taken.
104806 if(!p_igetw(&tempMsgString.h,f))
3893 {
3894 return qe_invalid;
3895 }
3896
3897
2/4
✓ Branch 0 taken 104806 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104806 times.
✗ Branch 3 not taken.
104806 if(!p_getc(&tempMsgString.hspace,f))
3898 {
3899 return qe_invalid;
3900 }
3901
3902
2/4
✓ Branch 0 taken 104806 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104806 times.
✗ Branch 3 not taken.
104806 if(!p_getc(&tempMsgString.vspace,f))
3903 {
3904 return qe_invalid;
3905 }
3906
3907
2/4
✓ Branch 0 taken 104806 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104806 times.
✗ Branch 3 not taken.
104806 if(!p_getc(&tempMsgString.stringflags,f))
3908 {
3909 return qe_invalid;
3910 }
3911 }
3912
3913
2/2
✓ Branch 0 taken 98962 times.
✓ Branch 1 taken 5844 times.
104806 if(s_version >= 7)
3914 {
3915
2/2
✓ Branch 0 taken 5844 times.
✓ Branch 1 taken 23376 times.
29220 for(int32_t q = 0; q < 4; ++q)
3916 {
3917
2/4
✓ Branch 0 taken 23376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23376 times.
✗ Branch 3 not taken.
23376 if(!p_getc(&tempMsgString.margins[q],f))
3918 {
3919 return qe_invalid;
3920 }
3921 23376 }
3922
3923
2/4
✓ Branch 0 taken 5844 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5844 times.
✗ Branch 3 not taken.
5844 if(!p_igetl(&tempMsgString.portrait_tile,f))
3924 {
3925 return qe_invalid;
3926 }
3927
3928
2/4
✓ Branch 0 taken 5844 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5844 times.
✗ Branch 3 not taken.
5844 if(!p_getc(&tempMsgString.portrait_cset,f))
3929 {
3930 return qe_invalid;
3931 }
3932
3933
2/4
✓ Branch 0 taken 5844 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5844 times.
✗ Branch 3 not taken.
5844 if(!p_getc(&tempMsgString.portrait_x,f))
3934 {
3935 return qe_invalid;
3936 }
3937
3938
2/4
✓ Branch 0 taken 5844 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5844 times.
✗ Branch 3 not taken.
5844 if(!p_getc(&tempMsgString.portrait_y,f))
3939 {
3940 return qe_invalid;
3941 }
3942
3943
2/4
✓ Branch 0 taken 5844 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5844 times.
✗ Branch 3 not taken.
5844 if(!p_getc(&tempMsgString.portrait_tw,f))
3944 {
3945 return qe_invalid;
3946 }
3947
3948
2/4
✓ Branch 0 taken 5844 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5844 times.
✗ Branch 3 not taken.
5844 if(!p_getc(&tempMsgString.portrait_th,f))
3949 {
3950 return qe_invalid;
3951 }
3952 5844 }
3953
3954
2/2
✓ Branch 0 taken 5844 times.
✓ Branch 1 taken 98962 times.
104806 if(s_version >= 8)
3955 {
3956
2/4
✓ Branch 0 taken 5844 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5844 times.
✗ Branch 3 not taken.
5844 if(!p_getc(&tempMsgString.shadow_type,f))
3957 {
3958 return qe_invalid;
3959 }
3960
3961
2/4
✓ Branch 0 taken 5844 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5844 times.
✗ Branch 3 not taken.
5844 if(!p_getc(&tempMsgString.shadow_color,f))
3962 {
3963 return qe_invalid;
3964 }
3965 5844 }
3966
3967
2/2
✓ Branch 0 taken 5535 times.
✓ Branch 1 taken 99271 times.
104806 if(s_version >= 10)
3968 {
3969
2/4
✓ Branch 0 taken 5535 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5535 times.
✗ Branch 3 not taken.
5535 if(!p_getc(&tempMsgString.drawlayer,f))
3970 {
3971 return qe_invalid;
3972 }
3973 5535 }
3974
3975
2/4
✓ Branch 0 taken 104806 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104806 times.
✗ Branch 3 not taken.
104806 if(!p_getc(&tempMsgString.sfx,f))
3976 {
3977 return qe_invalid;
3978 }
3979
3980
1/2
✓ Branch 0 taken 104806 times.
✗ Branch 1 not taken.
104806 if(s_version>3)
3981 {
3982
2/4
✓ Branch 0 taken 104806 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104806 times.
✗ Branch 3 not taken.
104806 if(!p_igetw(&tempMsgString.listpos,f))
3983 {
3984 return qe_invalid;
3985 }
3986 104806 }
3987 }
3988
3989
1/2
✓ Branch 0 taken 138419 times.
✗ Branch 1 not taken.
138419 if (!should_skip)
3990 {
3991
1/2
✓ Branch 0 taken 138419 times.
✗ Branch 1 not taken.
138419 MsgStrings[i].copyAll(tempMsgString);
3992 138419 }
3993 138419 }
3994 }
3995
3996
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 480 times.
481 if (!should_skip)
3997 480 msg_count=temp_msg_count;
3998
3999 481 return 0;
4000 481 }
4001
4002 481 int32_t readdoorcombosets(PACKFILE *f, zquestheader *Header)
4003 {
4004
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 457 times.
481 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_doors);
4005
4006
3/4
✓ Branch 0 taken 463 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
487 if((Header->zelda_version < 0x192)||
4007
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 457 times.
463 ((Header->zelda_version == 0x192)&&(Header->build<158)))
4008 {
4009 18 return 0;
4010 }
4011
4012 463 word temp_door_combo_set_count=0;
4013 DoorComboSet tempDoorComboSet;
4014 word dummy_word;
4015 int32_t dummy_long;
4016 byte padding;
4017 463 int32_t s_version = 0;
4018
4019
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 462 times.
463 if (!should_skip)
4020 {
4021 462 DoorComboSets = {};
4022 462 DoorComboSetNames = {};
4023 462 }
4024
4025
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 457 times.
463 if(Header->zelda_version > 0x192)
4026 {
4027 //section version info
4028
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 if(!p_igetw(&s_version,f))
4029 {
4030 return qe_invalid;
4031 }
4032
4033 457 FFCore.quest_format[vDoors] = s_version;
4034
4035
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 if(!p_igetw(&dummy_word,f))
4036 {
4037 return qe_invalid;
4038 }
4039
4040 //section size
4041
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 if(!p_igetl(&dummy_long,f))
4042 {
4043 return qe_invalid;
4044 }
4045 457 }
4046
4047 //finally... section data
4048
1/2
✓ Branch 0 taken 463 times.
✗ Branch 1 not taken.
463 if(!p_igetw(&temp_door_combo_set_count,f))
4049 {
4050 return qe_invalid;
4051 }
4052
4053
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 463 times.
463 if (temp_door_combo_set_count > MAXDOORCOMBOSETS)
4054 {
4055 return qe_invalid;
4056 }
4057
4058
2/2
✓ Branch 0 taken 5415 times.
✓ Branch 1 taken 463 times.
5878 for(int32_t i=0; i<temp_door_combo_set_count; i++)
4059 {
4060 5415 memset(&tempDoorComboSet, 0, sizeof(DoorComboSet));
4061
4062 //name
4063 char name[21];
4064
1/2
✓ Branch 0 taken 5415 times.
✗ Branch 1 not taken.
5415 if(!pfread(&name,sizeof(name),f))
4065 {
4066 return qe_invalid;
4067 }
4068
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 5401 times.
5415 if (!should_skip)
4069 5401 DoorComboSetNames[i] = name;
4070
4071
2/2
✓ Branch 0 taken 5375 times.
✓ Branch 1 taken 40 times.
5415 if(Header->zelda_version < 0x193)
4072 {
4073
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 if(!p_getc(&padding,f))
4074 {
4075 return qe_invalid;
4076 }
4077 40 }
4078
4079 //up door
4080
2/2
✓ Branch 0 taken 48735 times.
✓ Branch 1 taken 5415 times.
54150 for(int32_t j=0; j<9; j++)
4081 {
4082
2/2
✓ Branch 0 taken 194940 times.
✓ Branch 1 taken 48735 times.
243675 for(int32_t k=0; k<4; k++)
4083 {
4084
1/2
✓ Branch 0 taken 194940 times.
✗ Branch 1 not taken.
194940 if(!p_igetw(&tempDoorComboSet.doorcombo_u[j][k],f))
4085 {
4086 return qe_invalid;
4087 }
4088 194940 }
4089 48735 }
4090
4091
2/2
✓ Branch 0 taken 48735 times.
✓ Branch 1 taken 5415 times.
54150 for(int32_t j=0; j<9; j++)
4092 {
4093
2/2
✓ Branch 0 taken 194940 times.
✓ Branch 1 taken 48735 times.
243675 for(int32_t k=0; k<4; k++)
4094 {
4095
1/2
✓ Branch 0 taken 194940 times.
✗ Branch 1 not taken.
194940 if(!p_getc(&tempDoorComboSet.doorcset_u[j][k],f))
4096 {
4097 return qe_invalid;
4098 }
4099 194940 }
4100 48735 }
4101
4102 //down door
4103
2/2
✓ Branch 0 taken 48735 times.
✓ Branch 1 taken 5415 times.
54150 for(int32_t j=0; j<9; j++)
4104 {
4105
2/2
✓ Branch 0 taken 194940 times.
✓ Branch 1 taken 48735 times.
243675 for(int32_t k=0; k<4; k++)
4106 {
4107
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 194940 times.
194940 if(!p_igetw(&tempDoorComboSet.doorcombo_d[j][k],f))
4108 {
4109 return qe_invalid;
4110 }
4111 194940 }
4112 48735 }
4113
4114
2/2
✓ Branch 0 taken 48735 times.
✓ Branch 1 taken 5415 times.
54150 for(int32_t j=0; j<9; j++)
4115 {
4116
2/2
✓ Branch 0 taken 194940 times.
✓ Branch 1 taken 48735 times.
243675 for(int32_t k=0; k<4; k++)
4117 {
4118
1/2
✓ Branch 0 taken 194940 times.
✗ Branch 1 not taken.
194940 if(!p_getc(&tempDoorComboSet.doorcset_d[j][k],f))
4119 {
4120 return qe_invalid;
4121 }
4122 194940 }
4123 48735 }
4124
4125 //left door
4126
2/2
✓ Branch 0 taken 48735 times.
✓ Branch 1 taken 5415 times.
54150 for(int32_t j=0; j<9; j++)
4127 {
4128
2/2
✓ Branch 0 taken 292410 times.
✓ Branch 1 taken 48735 times.
341145 for(int32_t k=0; k<6; k++)
4129 {
4130
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 292410 times.
292410 if(!p_igetw(&tempDoorComboSet.doorcombo_l[j][k],f))
4131 {
4132 return qe_invalid;
4133 }
4134 292410 }
4135 48735 }
4136
4137
2/2
✓ Branch 0 taken 48735 times.
✓ Branch 1 taken 5415 times.
54150 for(int32_t j=0; j<9; j++)
4138 {
4139
2/2
✓ Branch 0 taken 292410 times.
✓ Branch 1 taken 48735 times.
341145 for(int32_t k=0; k<6; k++)
4140 {
4141
1/2
✓ Branch 0 taken 292410 times.
✗ Branch 1 not taken.
292410 if(!p_getc(&tempDoorComboSet.doorcset_l[j][k],f))
4142 {
4143 return qe_invalid;
4144 }
4145 292410 }
4146 48735 }
4147
4148 //right door
4149
2/2
✓ Branch 0 taken 48735 times.
✓ Branch 1 taken 5415 times.
54150 for(int32_t j=0; j<9; j++)
4150 {
4151
2/2
✓ Branch 0 taken 292410 times.
✓ Branch 1 taken 48735 times.
341145 for(int32_t k=0; k<6; k++)
4152 {
4153
1/2
✓ Branch 0 taken 292410 times.
✗ Branch 1 not taken.
292410 if(!p_igetw(&tempDoorComboSet.doorcombo_r[j][k],f))
4154 {
4155 return qe_invalid;
4156 }
4157 292410 }
4158 48735 }
4159
4160
2/2
✓ Branch 0 taken 48735 times.
✓ Branch 1 taken 5415 times.
54150 for(int32_t j=0; j<9; j++)
4161 {
4162
2/2
✓ Branch 0 taken 292410 times.
✓ Branch 1 taken 48735 times.
341145 for(int32_t k=0; k<6; k++)
4163 {
4164
1/2
✓ Branch 0 taken 292410 times.
✗ Branch 1 not taken.
292410 if(!p_getc(&tempDoorComboSet.doorcset_r[j][k],f))
4165 {
4166 return qe_invalid;
4167 }
4168 292410 }
4169 48735 }
4170
4171 //up bomb rubble
4172
2/2
✓ Branch 0 taken 10830 times.
✓ Branch 1 taken 5415 times.
16245 for(int32_t j=0; j<2; j++)
4173 {
4174
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10830 times.
10830 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_u[j],f))
4175 {
4176 return qe_invalid;
4177 }
4178 10830 }
4179
4180
2/2
✓ Branch 0 taken 10830 times.
✓ Branch 1 taken 5415 times.
16245 for(int32_t j=0; j<2; j++)
4181 {
4182
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10830 times.
10830 if(!p_getc(&tempDoorComboSet.bombdoorcset_u[j],f))
4183 {
4184 return qe_invalid;
4185 }
4186 10830 }
4187
4188 //down bomb rubble
4189
2/2
✓ Branch 0 taken 10830 times.
✓ Branch 1 taken 5415 times.
16245 for(int32_t j=0; j<2; j++)
4190 {
4191
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10830 times.
10830 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_d[j],f))
4192 {
4193 return qe_invalid;
4194 }
4195 10830 }
4196
4197
2/2
✓ Branch 0 taken 10830 times.
✓ Branch 1 taken 5415 times.
16245 for(int32_t j=0; j<2; j++)
4198 {
4199
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10830 times.
10830 if(!p_getc(&tempDoorComboSet.bombdoorcset_d[j],f))
4200 {
4201 return qe_invalid;
4202 }
4203 10830 }
4204
4205 //left bomb rubble
4206
2/2
✓ Branch 0 taken 16245 times.
✓ Branch 1 taken 5415 times.
21660 for(int32_t j=0; j<3; j++)
4207 {
4208
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16245 times.
16245 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_l[j],f))
4209 {
4210 return qe_invalid;
4211 }
4212 16245 }
4213
4214
2/2
✓ Branch 0 taken 16245 times.
✓ Branch 1 taken 5415 times.
21660 for(int32_t j=0; j<3; j++)
4215 {
4216
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16245 times.
16245 if(!p_getc(&tempDoorComboSet.bombdoorcset_l[j],f))
4217 {
4218 return qe_invalid;
4219 }
4220 16245 }
4221
4222
2/2
✓ Branch 0 taken 5375 times.
✓ Branch 1 taken 40 times.
5415 if(Header->zelda_version < 0x193)
4223 {
4224
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
40 if(!p_getc(&padding,f))
4225 {
4226 return qe_invalid;
4227 }
4228
4229 40 }
4230
4231 //right bomb rubble
4232
2/2
✓ Branch 0 taken 16245 times.
✓ Branch 1 taken 5415 times.
21660 for(int32_t j=0; j<3; j++)
4233 {
4234
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16245 times.
16245 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_r[j],f))
4235 {
4236 return qe_invalid;
4237 }
4238 16245 }
4239
4240
2/2
✓ Branch 0 taken 16245 times.
✓ Branch 1 taken 5415 times.
21660 for(int32_t j=0; j<3; j++)
4241 {
4242
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16245 times.
16245 if(!p_getc(&tempDoorComboSet.bombdoorcset_r[j],f))
4243 {
4244 return qe_invalid;
4245 }
4246 16245 }
4247
4248
2/2
✓ Branch 0 taken 5375 times.
✓ Branch 1 taken 40 times.
5415 if(Header->zelda_version < 0x193)
4249 {
4250
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
40 if(!p_getc(&padding,f))
4251 {
4252 return qe_invalid;
4253 }
4254 40 }
4255
4256 //walkthrough stuff
4257
2/2
✓ Branch 0 taken 21660 times.
✓ Branch 1 taken 5415 times.
27075 for(int32_t j=0; j<4; j++)
4258 {
4259
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21660 times.
21660 if(!p_igetw(&tempDoorComboSet.walkthroughcombo[j],f))
4260 {
4261 return qe_invalid;
4262 }
4263 21660 }
4264
4265
2/2
✓ Branch 0 taken 21660 times.
✓ Branch 1 taken 5415 times.
27075 for(int32_t j=0; j<4; j++)
4266 {
4267
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21660 times.
21660 if(!p_getc(&tempDoorComboSet.walkthroughcset[j],f))
4268 {
4269 return qe_invalid;
4270 }
4271 21660 }
4272
4273 //flags
4274
2/2
✓ Branch 0 taken 10830 times.
✓ Branch 1 taken 5415 times.
16245 for(int32_t j=0; j<2; j++)
4275 {
4276
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10830 times.
10830 if(!p_getc(&tempDoorComboSet.flags[j],f))
4277 {
4278 return qe_invalid;
4279 }
4280 10830 }
4281
4282
2/2
✓ Branch 0 taken 5375 times.
✓ Branch 1 taken 40 times.
5415 if(Header->zelda_version < 0x193)
4283 {
4284
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
40 if(!pfread(&tempDoorComboSet.expansion,sizeof(tempDoorComboSet.expansion),f))
4285 {
4286 return qe_invalid;
4287 }
4288 40 }
4289
4290
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 5401 times.
5415 if (!should_skip)
4291 5401 memcpy(&DoorComboSets[i], &tempDoorComboSet, sizeof(tempDoorComboSet));
4292 5415 }
4293
4294
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 462 times.
463 if (!should_skip)
4295 462 door_combo_set_count=temp_door_combo_set_count;
4296
4297 463 return 0;
4298 481 }
4299
4300 9 int32_t count_dmaps()
4301 {
4302 9 int32_t i=MAXDMAPS-1;
4303 9 bool found=false;
4304
4305
4/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 9 times.
9 while(i>=0 && !found)
4306 {
4307
4/6
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9 times.
✗ Branch 5 not taken.
27 if((DMaps[i].map!=0)||(DMaps[i].level!=0)||(DMaps[i].xoff!=0)||
4308
3/6
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9 times.
✗ Branch 5 not taken.
9 (DMaps[i].compass!=0)||(DMaps[i].color!=0)||(DMaps[i].midi!=0)||
4309
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 (DMaps[i].cont!=0)||(DMaps[i].type!=0))
4310 18 found=true;
4311
4312
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
90 for(int32_t j=0; j<8; j++)
4313 {
4314
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
72 if(DMaps[i].grid[j]!=0)
4315
4316 found=true;
4317 72 }
4318
4319
5/6
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
✓ Branch 4 taken 9 times.
✓ Branch 5 taken 9 times.
18 if((DMaps[i].name[0]!=0)||(DMaps[i].title[0]!=0)||
4320 (DMaps[i].intro[0]!=0)||(DMaps[i].tmusic[0]!=0))
4321 27 found=true;
4322
4323
3/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
27 if((DMaps[i].minimap_tile[0]!=0)||(DMaps[i].minimap_tile[1]!=0)||
4324
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 (DMaps[i].largemap_tile[0]!=0)||(DMaps[i].largemap_tile[1]!=0)||
4325
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 (DMaps[i].minimap_cset[0]!=0)||(DMaps[i].minimap_cset[1]!=0)||
4326
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 (DMaps[i].largemap_cset[0]!=0)||(DMaps[i].largemap_cset[1]!=0))
4327 18 found=true;
4328
4329 if(!found)
4330 {
4331 i--;
4332 }
4333 }
4334
4335 9 return i+1;
4336 }
4337
4338
4339 9 int32_t count_shops(miscQdata *Misc)
4340 {
4341 9 int32_t i=NUM_SHOPS-1,j;
4342 9 bool found=false;
4343
4344
4/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2234 times.
✓ Branch 2 taken 2229 times.
✓ Branch 3 taken 9 times.
2238 while(i>=0 && !found)
4345 {
4346 2229 j=2;
4347
4348
4/4
✓ Branch 0 taken 2224 times.
✓ Branch 1 taken 6682 times.
✓ Branch 2 taken 6677 times.
✓ Branch 3 taken 2229 times.
8906 while(j>=0 && !found)
4349 {
4350
3/4
✓ Branch 0 taken 6672 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6672 times.
6677 if((Misc->shop[i].hasitem[j]!=0)||(Misc->shop[i].price[j]!=0))
4351 {
4352 5 found=true;
4353 5 }
4354 else
4355 {
4356 6672 j--;
4357 }
4358 }
4359
4360
1/2
✓ Branch 0 taken 2229 times.
✗ Branch 1 not taken.
2229 if(Misc->shop[i].name[0]!=0)
4361 {
4362 found=true;
4363 }
4364
4365
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2224 times.
2229 if(!found)
4366 {
4367 2224 i--;
4368 2224 }
4369 }
4370
4371 9 return i+1;
4372 }
4373
4374 9 int32_t count_infos(miscQdata *Misc)
4375 {
4376 9 int32_t i=255,j;
4377 9 bool found=false;
4378
4379
4/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2234 times.
✓ Branch 2 taken 2229 times.
✓ Branch 3 taken 9 times.
2238 while(i>=0 && !found)
4380 {
4381 2229 j=2;
4382
4383
4/4
✓ Branch 0 taken 2224 times.
✓ Branch 1 taken 6682 times.
✓ Branch 2 taken 6677 times.
✓ Branch 3 taken 2229 times.
8906 while(j>=0 && !found)
4384 {
4385
4/4
✓ Branch 0 taken 6676 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 6672 times.
6677 if((Misc->info[i].str[j]!=0)||(Misc->info[i].price[j]!=0))
4386 {
4387 5 found=true;
4388 5 }
4389 else
4390 {
4391 6672 j--;
4392 }
4393 }
4394
4395
1/2
✓ Branch 0 taken 2229 times.
✗ Branch 1 not taken.
2229 if(Misc->info[i].name[0]!=0)
4396 {
4397 found=true;
4398 }
4399
4400
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2224 times.
2229 if(!found)
4401 {
4402 2224 i--;
4403 2224 }
4404 }
4405
4406 9 return i+1;
4407 }
4408
4409 9 int32_t count_warprings(miscQdata *Misc)
4410 {
4411 9 int32_t i=15,j;
4412 9 bool found=false;
4413
4414
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
✓ Branch 2 taken 49 times.
✓ Branch 3 taken 9 times.
58 while(i>=0 && !found)
4415 {
4416 49 j=7;
4417
4418
4/4
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 367 times.
✓ Branch 2 taken 358 times.
✓ Branch 3 taken 49 times.
407 while(j>=0 && !found)
4419 {
4420
4/4
✓ Branch 0 taken 354 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 349 times.
358 if((Misc->warp[i].dmap[j]!=0)||(Misc->warp[i].scr[j]!=0))
4421 {
4422 9 found=true;
4423 9 }
4424 else
4425 {
4426 349 j--;
4427 }
4428 }
4429
4430
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 40 times.
49 if(!found)
4431 {
4432 40 i--;
4433 40 }
4434 }
4435
4436 9 return i+1;
4437 }
4438
4439 9 int32_t count_palcycles(miscQdata *Misc)
4440 {
4441 9 int32_t i=255,j;
4442 9 bool found=false;
4443
4444
4/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2043 times.
✓ Branch 2 taken 2036 times.
✓ Branch 3 taken 9 times.
2045 while(i>=0 && !found)
4445 {
4446 2036 j=2;
4447
4448
4/4
✓ Branch 0 taken 2029 times.
✓ Branch 1 taken 6101 times.
✓ Branch 2 taken 6094 times.
✓ Branch 3 taken 2036 times.
8130 while(j>=0 && !found)
4449 {
4450
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 6087 times.
6094 if(Misc->cycles[i][j].count!=0)
4451 {
4452 7 found=true;
4453 7 }
4454 else
4455 {
4456 6087 j--;
4457 }
4458 }
4459
4460
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 2029 times.
2036 if(!found)
4461 {
4462 2029 i--;
4463 2029 }
4464 }
4465
4466 9 return i+1;
4467 }
4468
4469 18088 void clear_screen(mapscr *temp_scr)
4470 {
4471 18088 temp_scr->zero_memory();
4472 18088 }
4473
4474 // NOTE: when modifying this, you need to also update:
4475 // readonedmap, readdmaps, and FFScript::read_dmaps
4476 // (and their associated write functions)
4477 3553 int32_t readdmaps(PACKFILE *f, zquestheader *Header, word, word, word start_dmap, word max_dmaps)
4478 {
4479
2/2
✓ Branch 0 taken 3529 times.
✓ Branch 1 taken 24 times.
3553 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_dmaps);
4480
4481 3553 word dmapstoread=0;
4482 3553 dmap tempDMap;
4483
4484 int32_t dummy;
4485 3553 word s_version=0;
4486 byte padding;
4487
4488 char legacy_title[22];
4489
4490
2/2
✓ Branch 0 taken 3073 times.
✓ Branch 1 taken 480 times.
3553 if (!should_skip)
4491
2/2
✓ Branch 0 taken 245760 times.
✓ Branch 1 taken 480 times.
246240 for(int32_t i=0; i<max_dmaps; i++)
4492 {
4493
1/2
✓ Branch 0 taken 245760 times.
✗ Branch 1 not taken.
245760 DMaps[start_dmap + i].clear();
4494 245760 sprintf(legacy_title," ");
4495 245760 sprintf(DMaps[start_dmap+i].intro," ");
4496 245760 DMaps[start_dmap+i].type |= dmCAVE;
4497 246240 }
4498
4499
3/4
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 3073 times.
✓ Branch 2 taken 480 times.
✗ Branch 3 not taken.
3553 if (!should_skip && s_version == 21)
4500 Regions = {};
4501
4502 3553 Header->is_z3 = false;
4503
4/4
✓ Branch 0 taken 481 times.
✓ Branch 1 taken 3072 times.
✓ Branch 2 taken 457 times.
✓ Branch 3 taken 24 times.
3553 if(!Header || Header->zelda_version > 0x192)
4504 {
4505 //section version info
4506
3/4
✓ Branch 0 taken 457 times.
✓ Branch 1 taken 3072 times.
✓ Branch 2 taken 457 times.
✗ Branch 3 not taken.
3529 if(!p_igetw(&s_version,f))
4507 {
4508 return qe_invalid;
4509 }
4510 457 Header->is_z3 = s_version >= 22;
4511
4512 457 FFCore.quest_format[vDMaps] = s_version;
4513
4514
4515
2/4
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 457 times.
✗ Branch 3 not taken.
457 if(!read_deprecated_section_cversion(f))
4516 {
4517 return qe_invalid;
4518 }
4519
4520 //section size
4521
2/4
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 457 times.
✗ Branch 3 not taken.
457 if(!p_igetl(&dummy,f))
4522 {
4523 return qe_invalid;
4524 }
4525
4526 //finally... section data
4527
2/4
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 457 times.
✗ Branch 3 not taken.
457 if(!p_igetw(&dmapstoread,f))
4528 {
4529 return qe_invalid;
4530 }
4531 457 }
4532 else
4533 {
4534
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
30 if((Header->zelda_version < 0x192)||
4535
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((Header->zelda_version == 0x192)&&(Header->build<5)))
4536 {
4537 18 dmapstoread=32;
4538 18 }
4539
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 else if(s_version <= 4)
4540 {
4541 6 dmapstoread=OLDMAXDMAPS;
4542 6 }
4543 else
4544 {
4545 dmapstoread=MAXDMAPS;
4546 }
4547 }
4548
4549
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 398 times.
481 dmapstoread=zc_min(dmapstoread, max_dmaps);
4550
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 398 times.
481 dmapstoread=zc_min(dmapstoread, MAXDMAPS-start_dmap);
4551
4552
2/2
✓ Branch 0 taken 220992 times.
✓ Branch 1 taken 481 times.
221473 for(int32_t i=start_dmap; i<dmapstoread+start_dmap; i++)
4553 {
4554
1/2
✓ Branch 0 taken 220992 times.
✗ Branch 1 not taken.
220992 tempDMap.clear();
4555 220992 sprintf(legacy_title," ");
4556 220992 sprintf(tempDMap.intro," ");
4557
4558
2/4
✓ Branch 0 taken 220992 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 220992 times.
✗ Branch 3 not taken.
220992 if(!p_getc(&tempDMap.map,f))
4559 {
4560 return qe_invalid;
4561 }
4562
4563
2/2
✓ Branch 0 taken 17216 times.
✓ Branch 1 taken 203776 times.
220992 if(s_version <= 4)
4564 {
4565 byte tempbyte;
4566
4567
2/4
✓ Branch 0 taken 17216 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17216 times.
✗ Branch 3 not taken.
17216 if(!p_getc(&tempbyte,f))
4568 {
4569 return qe_invalid;
4570 }
4571
4572 17216 tempDMap.level=(word)tempbyte;
4573 17216 }
4574 else
4575 {
4576
2/4
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 203776 times.
✗ Branch 3 not taken.
203776 if(!p_igetw(&tempDMap.level,f))
4577 {
4578 return qe_invalid;
4579 }
4580 }
4581
4582
2/4
✓ Branch 0 taken 220992 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 220992 times.
✗ Branch 3 not taken.
220992 if(!p_getc(&tempDMap.xoff,f))
4583 {
4584 return qe_invalid;
4585 }
4586
4587
2/4
✓ Branch 0 taken 220992 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 220992 times.
✗ Branch 3 not taken.
220992 if(!p_getc(&tempDMap.compass,f))
4588 {
4589 return qe_invalid;
4590 }
4591
4592
2/2
✓ Branch 0 taken 203776 times.
✓ Branch 1 taken 17216 times.
220992 if(s_version > 8) // February 2009
4593 {
4594
2/4
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 203776 times.
✗ Branch 3 not taken.
203776 if(!p_igetw(&tempDMap.color,f))
4595 {
4596 return qe_invalid;
4597 }
4598 203776 }
4599 else
4600 {
4601 byte tempbyte;
4602
4603
2/4
✓ Branch 0 taken 17216 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17216 times.
✗ Branch 3 not taken.
17216 if(!p_getc(&tempbyte,f))
4604 {
4605 return qe_invalid;
4606 }
4607
4608 17216 tempDMap.color = (word)tempbyte;
4609 }
4610
4611
2/4
✓ Branch 0 taken 220992 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 220992 times.
✗ Branch 3 not taken.
220992 if(!p_getc(&tempDMap.midi,f))
4612 {
4613 return qe_invalid;
4614 }
4615
4616
2/4
✓ Branch 0 taken 220992 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 220992 times.
✗ Branch 3 not taken.
220992 if(!p_getc(&tempDMap.cont,f))
4617 {
4618 return qe_invalid;
4619 }
4620
4621
2/4
✓ Branch 0 taken 220992 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 220992 times.
✗ Branch 3 not taken.
220992 if(!p_getc(&tempDMap.type,f))
4622 {
4623 return qe_invalid;
4624 }
4625
4626
4/4
✓ Branch 0 taken 5961 times.
✓ Branch 1 taken 215031 times.
✓ Branch 2 taken 5917 times.
✓ Branch 3 taken 44 times.
226953 if((tempDMap.type & dmfTYPE) == dmOVERW &&
4627
1/2
✓ Branch 0 taken 5961 times.
✗ Branch 1 not taken.
5961 (!Header || Header->zelda_version >= 0x210)) // Not sure exactly when this changed
4628 5917 tempDMap.xoff = 0;
4629
4630
2/2
✓ Branch 0 taken 220992 times.
✓ Branch 1 taken 1767936 times.
1988928 for(int32_t j=0; j<8; j++)
4631 {
4632
2/4
✓ Branch 0 taken 1767936 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1767936 times.
✗ Branch 3 not taken.
1767936 if(!p_getc(&tempDMap.grid[j],f))
4633 {
4634 return qe_invalid;
4635 }
4636 1767936 }
4637
4638
5/6
✓ Branch 0 taken 220992 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 220416 times.
✓ Branch 3 taken 576 times.
✓ Branch 4 taken 1536 times.
✓ Branch 5 taken 218880 times.
220992 if(Header && ((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<41))))
4639 {
4640
4/4
✓ Branch 0 taken 137 times.
✓ Branch 1 taken 1975 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 127 times.
2112 if(tempDMap.level>0&&tempDMap.level<10)
4641 {
4642 127 sprintf(legacy_title,"LEVEL-%d ", tempDMap.level);
4643 127 }
4644
2/2
✓ Branch 0 taken 576 times.
✓ Branch 1 taken 1536 times.
2112 tempDMap.title.assign(legacy_title);
4645
4646
3/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 558 times.
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
576 if(i==0 && Header->zelda_version <= 0x190)
4647 {
4648
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 tempDMap.cont = std::max((int)tempDMap.cont - tempDMap.xoff, 0);
4649
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 tempDMap.compass = std::max((int)tempDMap.compass - tempDMap.xoff, 0);
4650 18 }
4651
4652 //forgotten -DD
4653
2/2
✓ Branch 0 taken 137 times.
✓ Branch 1 taken 439 times.
576 if(tempDMap.level==0)
4654 {
4655 439 tempDMap.flags=dmfCAVES|dmf3STAIR|dmfWHIRLWIND|dmfGUYCAVES;
4656 439 }
4657 576 }
4658 else
4659 {
4660
3/4
✓ Branch 0 taken 220416 times.
✓ Branch 1 taken 1536 times.
✓ Branch 2 taken 220416 times.
✗ Branch 3 not taken.
218880 if(!p_getstr(tempDMap.name,sizeof(DMaps[0].name) - 1,f))
4661 {
4662 return qe_invalid;
4663 }
4664
4665
2/2
✓ Branch 0 taken 130816 times.
✓ Branch 1 taken 89600 times.
220416 if(s_version<20)
4666 {
4667
2/4
✓ Branch 0 taken 130816 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 130816 times.
✗ Branch 3 not taken.
130816 if (!p_getstr(legacy_title, sizeof(legacy_title) - 1, f))
4668 {
4669 return qe_invalid;
4670 }
4671
1/2
✓ Branch 0 taken 130816 times.
✗ Branch 1 not taken.
130816 tempDMap.title.assign(legacy_title);
4672 130816 }
4673 else
4674 {
4675
2/4
✓ Branch 0 taken 89600 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 89600 times.
✗ Branch 3 not taken.
89600 if (!p_getwstr(&tempDMap.title, f))
4676 {
4677 return qe_invalid;
4678 }
4679 }
4680
4681
2/4
✓ Branch 0 taken 220416 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 220416 times.
✗ Branch 3 not taken.
220416 if(!p_getstr(tempDMap.intro,sizeof(DMaps[0].intro)-1,f))
4682 {
4683 return qe_invalid;
4684 }
4685
4686
5/8
✓ Branch 0 taken 220416 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 220416 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1536 times.
✓ Branch 5 taken 218880 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1536 times.
220416 if(Header && ((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<152))))
4687 {
4688 if ((tempDMap.type & dmfTYPE) == dmOVERW) tempDMap.flags = dmfCAVES | dmf3STAIR | dmfWHIRLWIND | dmfGUYCAVES;
4689 DMaps[i] = tempDMap;
4690
4691 continue;
4692 }
4693
4694
3/4
✓ Branch 0 taken 220416 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✓ Branch 3 taken 218880 times.
220416 if(Header && (Header->zelda_version < 0x193))
4695 {
4696
2/4
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
1536 if(!p_getc(&padding,f))
4697 {
4698 return qe_invalid;
4699 }
4700 1536 }
4701
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 122112 times.
220416 if ( s_version >= 11 )
4702 {
4703
2/4
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98304 times.
✗ Branch 3 not taken.
98304 if(!p_igetl(&tempDMap.minimap_tile[0],f))
4704 {
4705 return qe_invalid;
4706 }
4707 98304 }
4708 else
4709 {
4710
2/4
✓ Branch 0 taken 122112 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 122112 times.
✗ Branch 3 not taken.
122112 if(!p_igetw(&tempDMap.minimap_tile[0],f))
4711 {
4712 return qe_invalid;
4713 }
4714 }
4715
4716
2/4
✓ Branch 0 taken 220416 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 220416 times.
✗ Branch 3 not taken.
220416 if(!p_getc(&tempDMap.minimap_cset[0],f))
4717 {
4718 return qe_invalid;
4719 }
4720
4721
3/4
✓ Branch 0 taken 220416 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✓ Branch 3 taken 218880 times.
220416 if(Header && (Header->zelda_version < 0x193))
4722 {
4723
2/4
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
1536 if(!p_getc(&padding,f))
4724 {
4725 return qe_invalid;
4726 }
4727 1536 }
4728
4729
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 122112 times.
220416 if ( s_version >= 11 )
4730 {
4731
2/4
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98304 times.
✗ Branch 3 not taken.
98304 if(!p_igetl(&tempDMap.minimap_tile[1],f))
4732 {
4733 return qe_invalid;
4734 }
4735 98304 }
4736 else
4737 {
4738
2/4
✓ Branch 0 taken 122112 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 122112 times.
✗ Branch 3 not taken.
122112 if(!p_igetw(&tempDMap.minimap_tile[1],f))
4739 {
4740 return qe_invalid;
4741 }
4742 }
4743
2/4
✓ Branch 0 taken 220416 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 220416 times.
✗ Branch 3 not taken.
220416 if(!p_getc(&tempDMap.minimap_cset[1],f))
4744 {
4745 return qe_invalid;
4746 }
4747
4748
3/4
✓ Branch 0 taken 220416 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✓ Branch 3 taken 218880 times.
220416 if(Header && (Header->zelda_version < 0x193))
4749 {
4750
2/4
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
1536 if(!p_getc(&padding,f))
4751 {
4752 return qe_invalid;
4753 }
4754 1536 }
4755
4756
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 122112 times.
220416 if ( s_version >= 11 )
4757 {
4758
2/4
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98304 times.
✗ Branch 3 not taken.
98304 if(!p_igetl(&tempDMap.largemap_tile[0],f))
4759 {
4760 return qe_invalid;
4761 }
4762 98304 }
4763 else
4764 {
4765
2/4
✓ Branch 0 taken 122112 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 122112 times.
✗ Branch 3 not taken.
122112 if(!p_igetw(&tempDMap.largemap_tile[0],f))
4766 {
4767 return qe_invalid;
4768 }
4769 }
4770
4771
2/4
✓ Branch 0 taken 220416 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 220416 times.
✗ Branch 3 not taken.
220416 if(!p_getc(&tempDMap.largemap_cset[0],f))
4772 {
4773 return qe_invalid;
4774 }
4775
4776
3/4
✓ Branch 0 taken 220416 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✓ Branch 3 taken 218880 times.
220416 if(Header && (Header->zelda_version < 0x193))
4777 {
4778
4779
2/4
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
1536 if(!p_getc(&padding,f))
4780 {
4781 return qe_invalid;
4782 }
4783 1536 }
4784
4785
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 122112 times.
220416 if ( s_version >= 11 )
4786 {
4787
2/4
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98304 times.
✗ Branch 3 not taken.
98304 if(!p_igetl(&tempDMap.largemap_tile[1],f))
4788 {
4789 return qe_invalid;
4790 }
4791 98304 }
4792 else
4793 {
4794
2/4
✓ Branch 0 taken 122112 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 122112 times.
✗ Branch 3 not taken.
122112 if(!p_igetw(&tempDMap.largemap_tile[1],f))
4795 {
4796 return qe_invalid;
4797 }
4798 }
4799
2/4
✓ Branch 0 taken 220416 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 220416 times.
✗ Branch 3 not taken.
220416 if(!p_getc(&tempDMap.largemap_cset[1],f))
4800 {
4801 return qe_invalid;
4802 }
4803
4804
2/4
✓ Branch 0 taken 220416 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 220416 times.
✗ Branch 3 not taken.
220416 if(!p_getstr(tempDMap.tmusic,sizeof(DMaps[0].tmusic)-1,f))
4805 {
4806 return qe_invalid;
4807 }
4808 }
4809
4810
2/2
✓ Branch 0 taken 203776 times.
✓ Branch 1 taken 17216 times.
220992 if(s_version>1)
4811 {
4812
2/4
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 203776 times.
✗ Branch 3 not taken.
203776 if(!p_getc(&tempDMap.tmusictrack,f))
4813 {
4814 return qe_invalid;
4815 }
4816
4817
2/4
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 203776 times.
✗ Branch 3 not taken.
203776 if(!p_getc(&tempDMap.active_subscreen,f))
4818 {
4819 return qe_invalid;
4820 }
4821
4822
2/4
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 203776 times.
✗ Branch 3 not taken.
203776 if(!p_getc(&tempDMap.passive_subscreen,f))
4823 {
4824 return qe_invalid;
4825 }
4826 203776 }
4827
4828
2/2
✓ Branch 0 taken 203776 times.
✓ Branch 1 taken 17216 times.
220992 if(s_version>2)
4829 {
4830 byte di[32];
4831
4832
2/4
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 203776 times.
✗ Branch 3 not taken.
203776 if(!pfread(&di, 32, f)) return qe_invalid;
4833
4834
2/2
✓ Branch 0 taken 52166656 times.
✓ Branch 1 taken 203776 times.
52370432 for(int32_t j=0; j<MAXITEMS; j++)
4835 {
4836
2/2
✓ Branch 0 taken 9207 times.
✓ Branch 1 taken 52157449 times.
52166656 if(di[j/8] & (1 << (j%8))) tempDMap.disableditems[j]=1;
4837 52157449 else tempDMap.disableditems[j]=0;
4838 52166656 }
4839 203776 }
4840
4841
2/2
✓ Branch 0 taken 203776 times.
✓ Branch 1 taken 17216 times.
220992 if(s_version >= 6)
4842 {
4843
2/4
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 203776 times.
✗ Branch 3 not taken.
203776 if(!p_igetl(&tempDMap.flags,f))
4844 {
4845 return qe_invalid;
4846 }
4847 203776 }
4848
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17216 times.
17216 else if(s_version>3)
4849 {
4850 char temp;
4851
4852 if(!p_getc(&temp,f))
4853 {
4854 return qe_invalid;
4855 }
4856
4857 tempDMap.flags = temp;
4858 }
4859
3/8
✓ Branch 0 taken 8992 times.
✓ Branch 1 taken 8224 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8992 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
17216 else if(tempDMap.level==0 && ((Header->zelda_version < 0x211) || ((Header->zelda_version == 0x211) && (Header->build<18))))
4860 {
4861 8992 tempDMap.flags=dmfCAVES|dmf3STAIR|dmfWHIRLWIND|dmfGUYCAVES;
4862 8992 }
4863 else
4864 8224 tempDMap.flags=0;
4865
4866
2/2
✓ Branch 0 taken 203776 times.
✓ Branch 1 taken 17216 times.
220992 if(s_version<7)
4867 {
4868
5/6
✓ Branch 0 taken 8992 times.
✓ Branch 1 taken 8224 times.
✓ Branch 2 taken 8992 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2846 times.
✓ Branch 5 taken 6146 times.
17216 if(tempDMap.level==0 && get_bit(deprecated_rules,14))
4869 6146 tempDMap.flags|= dmfVIEWMAP;
4870 17216 }
4871
4872
2/2
✓ Branch 0 taken 203776 times.
✓ Branch 1 taken 17216 times.
220992 if(s_version<8)
4873 {
4874
4/4
✓ Branch 0 taken 8992 times.
✓ Branch 1 taken 8224 times.
✓ Branch 2 taken 8050 times.
✓ Branch 3 taken 942 times.
17216 if(tempDMap.level==0 && (tempDMap.type&dmfTYPE)==dmDNGN)
4875 {
4876
1/2
✓ Branch 0 taken 8050 times.
✗ Branch 1 not taken.
8050 tempDMap.type &= ~dmDNGN;
4877 8050 tempDMap.type |= dmCAVE;
4878 8050 }
4879
2/2
✓ Branch 0 taken 6834 times.
✓ Branch 1 taken 2332 times.
9166 else if((tempDMap.type&dmfTYPE)==dmCAVE)
4880 {
4881 2332 tempDMap.flags |= dmfMINIMAPCOLORFIX;
4882 2332 }
4883 17216 }
4884
4885
7/8
✓ Branch 0 taken 220992 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2112 times.
✓ Branch 3 taken 218880 times.
✓ Branch 4 taken 1536 times.
✓ Branch 5 taken 576 times.
✓ Branch 6 taken 1536 times.
✓ Branch 7 taken 218880 times.
220992 if(Header && ((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>=41)))
4886 220416 && (Header->zelda_version < 0x193))
4887 {
4888
2/4
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
1536 if(!p_getc(&padding,f))
4889 {
4890 return qe_invalid;
4891 }
4892 1536 }
4893
4894
2/2
✓ Branch 0 taken 122688 times.
✓ Branch 1 taken 98304 times.
220992 if(s_version >= 10)
4895 {
4896
2/4
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98304 times.
✗ Branch 3 not taken.
98304 if(!p_getc(&tempDMap.sideview,f))
4897 {
4898 return qe_invalid;
4899 }
4900 98304 }
4901
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 122688 times.
220992 if(s_version < 10) tempDMap.sideview = 0;
4902
4903 //Dmap Scripts
4904
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 122688 times.
220992 if(s_version >= 12)
4905 {
4906
2/4
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98304 times.
✗ Branch 3 not taken.
98304 if(!p_igetw(&tempDMap.script,f))
4907 {
4908 return qe_invalid;
4909 }
4910
2/2
✓ Branch 0 taken 786432 times.
✓ Branch 1 taken 98304 times.
884736 for ( int32_t q = 0; q < 8; q++ )
4911 {
4912
2/4
✓ Branch 0 taken 786432 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 786432 times.
✗ Branch 3 not taken.
786432 if(!p_igetl(&tempDMap.initD[q],f))
4913 {
4914 return qe_invalid;
4915 }
4916 786432 }
4917 98304 }
4918
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 122688 times.
220992 if ( s_version < 12 )
4919 {
4920 122688 tempDMap.script = 0;
4921
2/2
✓ Branch 0 taken 981504 times.
✓ Branch 1 taken 122688 times.
1104192 for ( int32_t q = 0; q < 8; q++ )
4922 {
4923 981504 tempDMap.initD[q] = 0;
4924 981504 }
4925 122688 }
4926
4927
2/2
✓ Branch 0 taken 122688 times.
✓ Branch 1 taken 98304 times.
220992 if(s_version >= 13)
4928 {
4929
2/2
✓ Branch 0 taken 786432 times.
✓ Branch 1 taken 98304 times.
884736 for ( int32_t q = 0; q < 8; q++ )
4930 {
4931
2/2
✓ Branch 0 taken 51118080 times.
✓ Branch 1 taken 786432 times.
51904512 for ( int32_t w = 0; w < 65; w++ )
4932 {
4933
2/4
✓ Branch 0 taken 51118080 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 51118080 times.
✗ Branch 3 not taken.
51118080 if(!p_getc(&tempDMap.initD_label[q][w],f))
4934 {
4935 return qe_invalid;
4936 }
4937 51118080 }
4938 786432 }
4939 98304 }
4940
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 122688 times.
220992 if ( s_version < 13 )
4941 {
4942 122688 tempDMap.script = 0;
4943
2/2
✓ Branch 0 taken 981504 times.
✓ Branch 1 taken 122688 times.
1104192 for ( int32_t q = 0; q < 8; q++ )
4944 {
4945
2/2
✓ Branch 0 taken 63797760 times.
✓ Branch 1 taken 981504 times.
64779264 for ( int32_t w = 0; w < 65; w++ )
4946 63797760 tempDMap.initD_label[q][w] = 0;
4947 981504 }
4948 122688 }
4949
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 122688 times.
220992 if(s_version >= 14)
4950 {
4951
2/4
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98304 times.
✗ Branch 3 not taken.
98304 if(!p_igetw(&tempDMap.active_sub_script,f))
4952 {
4953 return qe_invalid;
4954 }
4955
2/4
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98304 times.
✗ Branch 3 not taken.
98304 if(!p_igetw(&tempDMap.passive_sub_script,f))
4956 {
4957 return qe_invalid;
4958 }
4959
2/2
✓ Branch 0 taken 786432 times.
✓ Branch 1 taken 98304 times.
884736 for ( int32_t q = 0; q < 8; ++q )
4960 {
4961
2/4
✓ Branch 0 taken 786432 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 786432 times.
✗ Branch 3 not taken.
786432 if(!p_igetl(&tempDMap.sub_initD[q],f))
4962 {
4963 return qe_invalid;
4964 }
4965 786432 }
4966
2/2
✓ Branch 0 taken 786432 times.
✓ Branch 1 taken 98304 times.
884736 for(int32_t q = 0; q < 8; ++q)
4967 {
4968
2/2
✓ Branch 0 taken 51118080 times.
✓ Branch 1 taken 786432 times.
51904512 for ( int32_t w = 0; w < 65; ++w )
4969 {
4970
2/4
✓ Branch 0 taken 51118080 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 51118080 times.
✗ Branch 3 not taken.
51118080 if(!p_getc(&tempDMap.sub_initD_label[q][w],f))
4971 {
4972 return qe_invalid;
4973 }
4974 51118080 }
4975 786432 }
4976 98304 }
4977 else
4978 {
4979 122688 tempDMap.active_sub_script = 0;
4980 122688 tempDMap.passive_sub_script = 0;
4981
2/2
✓ Branch 0 taken 981504 times.
✓ Branch 1 taken 122688 times.
1104192 for(int32_t q = 0; q < 8; ++q)
4982 {
4983 981504 tempDMap.sub_initD[q] = 0;
4984
2/2
✓ Branch 0 taken 63797760 times.
✓ Branch 1 taken 981504 times.
64779264 for(int32_t w = 0; w < 65; ++w)
4985 63797760 tempDMap.sub_initD_label[q][w] = 0;
4986 981504 }
4987 }
4988
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 122688 times.
220992 if(s_version >= 15)
4989 {
4990
2/4
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98304 times.
✗ Branch 3 not taken.
98304 if(!p_igetw(&tempDMap.onmap_script,f))
4991 {
4992 return qe_invalid;
4993 }
4994
2/2
✓ Branch 0 taken 786432 times.
✓ Branch 1 taken 98304 times.
884736 for ( int32_t q = 0; q < 8; ++q )
4995 {
4996
2/4
✓ Branch 0 taken 786432 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 786432 times.
✗ Branch 3 not taken.
786432 if(!p_igetl(&tempDMap.onmap_initD[q],f))
4997 {
4998 return qe_invalid;
4999 }
5000 786432 }
5001
2/2
✓ Branch 0 taken 786432 times.
✓ Branch 1 taken 98304 times.
884736 for(int32_t q = 0; q < 8; ++q)
5002 {
5003
2/2
✓ Branch 0 taken 51118080 times.
✓ Branch 1 taken 786432 times.
51904512 for ( int32_t w = 0; w < 65; ++w )
5004 {
5005
2/4
✓ Branch 0 taken 51118080 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 51118080 times.
✗ Branch 3 not taken.
51118080 if(!p_getc(&tempDMap.onmap_initD_label[q][w],f))
5006 {
5007 return qe_invalid;
5008 }
5009 51118080 }
5010 786432 }
5011 98304 }
5012 else
5013 {
5014 122688 tempDMap.onmap_script = 0;
5015
2/2
✓ Branch 0 taken 981504 times.
✓ Branch 1 taken 122688 times.
1104192 for(int32_t q = 0; q < 8; ++q)
5016 {
5017 981504 tempDMap.onmap_initD[q] = 0;
5018
2/2
✓ Branch 0 taken 63797760 times.
✓ Branch 1 taken 981504 times.
64779264 for(int32_t w = 0; w < 65; ++w)
5019 {
5020 63797760 tempDMap.onmap_initD_label[q][w] = 0;
5021 63797760 }
5022 981504 }
5023 }
5024
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 122688 times.
220992 if(s_version >= 16)
5025 {
5026
2/4
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98304 times.
✗ Branch 3 not taken.
98304 if(!p_igetw(&tempDMap.mirrorDMap,f))
5027 {
5028 return qe_invalid;
5029 }
5030 98304 }
5031 else
5032 {
5033 122688 tempDMap.mirrorDMap = -1;
5034 }
5035
5036 // Enhanced music loop points
5037
2/2
✓ Branch 0 taken 89600 times.
✓ Branch 1 taken 131392 times.
220992 if (s_version >= 18)
5038 {
5039
2/4
✓ Branch 0 taken 89600 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 89600 times.
✗ Branch 3 not taken.
89600 if (!p_igetl(&tempDMap.tmusic_loop_start, f))
5040 {
5041 return qe_invalid;
5042 }
5043
2/4
✓ Branch 0 taken 89600 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 89600 times.
✗ Branch 3 not taken.
89600 if (!p_igetl(&tempDMap.tmusic_loop_end, f))
5044 {
5045 return qe_invalid;
5046 }
5047
2/4
✓ Branch 0 taken 89600 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 89600 times.
✗ Branch 3 not taken.
89600 if (!p_igetl(&tempDMap.tmusic_xfade_in, f))
5048 {
5049 return qe_invalid;
5050 }
5051
2/4
✓ Branch 0 taken 89600 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 89600 times.
✗ Branch 3 not taken.
89600 if (!p_igetl(&tempDMap.tmusic_xfade_out, f))
5052 {
5053 return qe_invalid;
5054 }
5055 89600 }
5056 else
5057 {
5058 131392 tempDMap.tmusic_loop_start = 0;
5059 131392 tempDMap.tmusic_loop_end = 0;
5060 131392 tempDMap.tmusic_xfade_in = 0;
5061 131392 tempDMap.tmusic_xfade_out = 0;
5062 }
5063
5064
2/2
✓ Branch 0 taken 89600 times.
✓ Branch 1 taken 131392 times.
220992 if(s_version >= 19)
5065
2/4
✓ Branch 0 taken 89600 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 89600 times.
✗ Branch 3 not taken.
89600 if(!p_getc(&tempDMap.overlay_subscreen, f))
5066 return qe_invalid;
5067
5068
2/2
✓ Branch 0 taken 89600 times.
✓ Branch 1 taken 131392 times.
220992 if (s_version >= 20)
5069 {
5070
2/4
✓ Branch 0 taken 89600 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 89600 times.
✗ Branch 3 not taken.
89600 if (!p_igetl(&tempDMap.intro_string_id, f))
5071 return qe_invalid;
5072 89600 }
5073 else
5074 131392 tempDMap.intro_string_id = 0;
5075
5076
2/2
✓ Branch 0 taken 206656 times.
✓ Branch 1 taken 14336 times.
220992 if(s_version == 21)
5077 {
5078 static regions_data tmp_rd;
5079
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14336 times.
14336 regions_data& rd = should_skip ? tmp_rd : Regions[tempDMap.map];
5080
2/2
✓ Branch 0 taken 114688 times.
✓ Branch 1 taken 14336 times.
129024 for(int32_t j=0; j<8; j++)
5081 {
5082
2/2
✓ Branch 0 taken 917504 times.
✓ Branch 1 taken 114688 times.
1032192 for(int32_t k=0; k<8; k++)
5083 {
5084
2/4
✓ Branch 0 taken 917504 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 917504 times.
✗ Branch 3 not taken.
917504 if(!p_getc(&rd.region_ids[j][k],f))
5085 {
5086 return qe_invalid;
5087 }
5088 917504 }
5089 114688 }
5090 14336 }
5091
5092
2/2
✓ Branch 0 taken 220736 times.
✓ Branch 1 taken 256 times.
220992 if (!should_skip)
5093 {
5094
1/2
✓ Branch 0 taken 220736 times.
✗ Branch 1 not taken.
220736 if(loading_tileset_flags & TILESET_CLEARMAPS)
5095 tempDMap.map = 0;
5096
1/2
✓ Branch 0 taken 220736 times.
✗ Branch 1 not taken.
220736 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
5097 {
5098 tempDMap.script = 0;
5099 for(int q = 0; q < 8; ++q)
5100 tempDMap.initD[q] = 0;
5101 }
5102
1/2
✓ Branch 0 taken 220736 times.
✗ Branch 1 not taken.
220736 DMaps[i] = tempDMap;
5103 220736 }
5104 220992 }
5105
5106 481 return 0;
5107 6625 }
5108
5109 398 int32_t readmisccolors(PACKFILE *f, zquestheader *Header, miscQdata *Misc)
5110 {
5111 //these are here to bypass compiler warnings about unused arguments
5112 398 Header=Header;
5113
5114 miscQdata temp_misc;
5115 398 word s_version=0;
5116 398 int32_t tempsize=0;
5117 word dummyw;
5118
5119 398 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5120
5121 //section version info
5122
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 if(!p_igetw(&s_version,f))
5123 {
5124 return qe_invalid;
5125 }
5126
5127 398 FFCore.quest_format[vColours] = s_version;
5128
5129 398 al_trace("Misc Colours section version: %d\n", s_version);
5130
5131
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!read_deprecated_section_cversion(f))
5132 {
5133 return qe_invalid;
5134 }
5135
5136
5137 //section size
5138
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_igetl(&tempsize,f))
5139 {
5140 return qe_invalid;
5141 }
5142
5143 //finally... section data
5144 398 readsize=0;
5145
5146
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_getc(&temp_misc.colors.text,f))
5147 {
5148 return qe_invalid;
5149 }
5150
5151
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_getc(&temp_misc.colors.caption,f))
5152 {
5153 return qe_invalid;
5154 }
5155
5156
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_getc(&temp_misc.colors.overw_bg,f))
5157 {
5158 return qe_invalid;
5159 }
5160
5161
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_getc(&temp_misc.colors.dngn_bg,f))
5162 {
5163 return qe_invalid;
5164 }
5165
5166
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_getc(&temp_misc.colors.dngn_fg,f))
5167 {
5168 return qe_invalid;
5169 }
5170
5171
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_getc(&temp_misc.colors.cave_fg,f))
5172 {
5173 return qe_invalid;
5174 }
5175
5176
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_getc(&temp_misc.colors.bs_dk,f))
5177 {
5178 return qe_invalid;
5179 }
5180
5181
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_getc(&temp_misc.colors.bs_goal,f))
5182 {
5183 return qe_invalid;
5184 }
5185
5186
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_getc(&temp_misc.colors.compass_lt,f))
5187 {
5188 return qe_invalid;
5189 }
5190
5191
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_getc(&temp_misc.colors.compass_dk,f))
5192 {
5193 return qe_invalid;
5194 }
5195
5196
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_getc(&temp_misc.colors.subscr_bg,f))
5197 {
5198 return qe_invalid;
5199 }
5200
5201
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_getc(&temp_misc.colors.triframe_color,f))
5202 {
5203 return qe_invalid;
5204 }
5205
5206
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_getc(&temp_misc.colors.hero_dot,f))
5207 {
5208 return qe_invalid;
5209 }
5210
5211
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_getc(&temp_misc.colors.bmap_bg,f))
5212 {
5213 return qe_invalid;
5214 }
5215
5216
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_getc(&temp_misc.colors.bmap_fg,f))
5217 {
5218 return qe_invalid;
5219 }
5220
5221
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_getc(&temp_misc.colors.triforce_cset,f))
5222 {
5223 return qe_invalid;
5224 }
5225
5226
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_getc(&temp_misc.colors.triframe_cset,f))
5227 {
5228 return qe_invalid;
5229 }
5230
5231
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_getc(&temp_misc.colors.overworld_map_cset,f))
5232 {
5233 return qe_invalid;
5234 }
5235
5236
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_getc(&temp_misc.colors.dungeon_map_cset,f))
5237 {
5238 return qe_invalid;
5239 }
5240
5241
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_getc(&temp_misc.colors.blueframe_cset,f))
5242 {
5243 return qe_invalid;
5244 }
5245
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 206 times.
398 if(s_version < 4)
5246 {
5247
1/2
✓ Branch 0 taken 206 times.
✗ Branch 1 not taken.
206 if(!p_igetw(&dummyw,f))
5248 return qe_invalid;
5249 206 temp_misc.colors.triforce_tile = dummyw;
5250
5251
1/2
✓ Branch 0 taken 206 times.
✗ Branch 1 not taken.
206 if(!p_igetw(&dummyw,f))
5252 return qe_invalid;
5253 206 temp_misc.colors.triframe_tile = dummyw;
5254
5255
1/2
✓ Branch 0 taken 206 times.
✗ Branch 1 not taken.
206 if(!p_igetw(&dummyw,f))
5256 return qe_invalid;
5257 206 temp_misc.colors.overworld_map_tile = dummyw;
5258
5259
1/2
✓ Branch 0 taken 206 times.
✗ Branch 1 not taken.
206 if(!p_igetw(&dummyw,f))
5260 return qe_invalid;
5261 206 temp_misc.colors.dungeon_map_tile = dummyw;
5262
5263
1/2
✓ Branch 0 taken 206 times.
✗ Branch 1 not taken.
206 if(!p_igetw(&dummyw,f))
5264 return qe_invalid;
5265 206 temp_misc.colors.blueframe_tile = dummyw;
5266
5267
1/2
✓ Branch 0 taken 206 times.
✗ Branch 1 not taken.
206 if(!p_igetw(&dummyw,f))
5268 return qe_invalid;
5269 206 temp_misc.colors.HCpieces_tile = dummyw;
5270 206 }
5271
5272
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_getc(&temp_misc.colors.HCpieces_cset,f))
5273 {
5274 return qe_invalid;
5275 }
5276
5277
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_getc(&temp_misc.colors.subscr_shadow,f))
5278 {
5279 return qe_invalid;
5280 }
5281
5282
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 if(s_version < 2)
5283 {
5284 temp_misc.colors.msgtext = 0x01;
5285 }
5286 else
5287 {
5288
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_getc(&temp_misc.colors.msgtext, f))
5289 {
5290 return qe_invalid;
5291 }
5292 }
5293
5294
2/2
✓ Branch 0 taken 206 times.
✓ Branch 1 taken 192 times.
398 if ( s_version >= 3 ) //expanded tile pages to 825
5295 {
5296
1/2
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
192 if(!p_igetl(&temp_misc.colors.triforce_tile,f))
5297 {
5298 return qe_invalid;
5299 }
5300
5301
1/2
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
192 if(!p_igetl(&temp_misc.colors.triframe_tile,f))
5302 {
5303 return qe_invalid;
5304 }
5305
5306
1/2
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
192 if(!p_igetl(&temp_misc.colors.overworld_map_tile,f))
5307 {
5308 return qe_invalid;
5309 }
5310
5311
1/2
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
192 if(!p_igetl(&temp_misc.colors.dungeon_map_tile,f))
5312 {
5313 return qe_invalid;
5314 }
5315
5316
1/2
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
192 if(!p_igetl(&temp_misc.colors.blueframe_tile,f))
5317 {
5318 return qe_invalid;
5319 }
5320
5321
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if(!p_igetl(&temp_misc.colors.HCpieces_tile,f))
5322 {
5323 return qe_invalid;
5324 }
5325 192 }
5326
5327 398 memcpy(Misc, &temp_misc, sizeof(temp_misc));
5328
5329 398 return 0;
5330 398 }
5331
5332 398 int32_t readgameicons(PACKFILE *f, zquestheader *, miscQdata *Misc)
5333 {
5334 miscQdata temp_misc;
5335 398 word s_version=0;
5336 byte icons;
5337 398 int32_t tempsize=0;
5338
5339 398 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5340
5341 //section version info
5342
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 if(!p_igetw(&s_version,f))
5343 {
5344 return qe_invalid;
5345 }
5346
5347 398 FFCore.quest_format[vIcons] = s_version;
5348
5349
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!read_deprecated_section_cversion(f))
5350 {
5351 return qe_invalid;
5352 }
5353
5354
5355 //section size
5356
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_igetl(&tempsize,f))
5357 {
5358 return qe_invalid;
5359 }
5360
5361 //finally... section data
5362 398 readsize=0;
5363
5364 398 icons=4;
5365
5366
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 206 times.
398 if ( s_version >= 10 )
5367 {
5368
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 192 times.
960 for(int32_t i=0; i<icons; i++)
5369 {
5370
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 768 times.
768 if(!p_igetl(&temp_misc.icons[i],f))
5371 {
5372 return qe_invalid;
5373 }
5374 768 }
5375 192 }
5376 else
5377 {
5378
2/2
✓ Branch 0 taken 824 times.
✓ Branch 1 taken 206 times.
1030 for(int32_t i=0; i<icons; i++)
5379 {
5380
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 824 times.
824 if(!p_igetw(&temp_misc.icons[i],f))
5381 {
5382 return qe_invalid;
5383 }
5384 824 }
5385 }
5386
5387 398 memcpy(Misc, &temp_misc, sizeof(temp_misc));
5388
5389 398 return 0;
5390 398 }
5391
5392 804 int32_t readmisc(PACKFILE *f, zquestheader *Header, miscQdata *Misc)
5393 {
5394
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 780 times.
804 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_misc);
5395
5396 804 word maxinfos=256;
5397 804 word maxshops=256;
5398 804 word shops=16, infos=16, warprings=8, palcycles=256, windwarps=9, triforces=8, icons=4;
5399 804 word ponds=16, pondsize=72, expansionsize=98*2;
5400 byte tempbyte, padding;
5401 miscQdata temp_misc;
5402 804 word s_version=0;
5403 word swaptmp;
5404 804 int32_t tempsize=0;
5405
5406 804 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5407
5408
2/2
✓ Branch 0 taken 205824 times.
✓ Branch 1 taken 804 times.
206628 for(int32_t i=0; i<maxshops; ++i)
5409 {
5410 205824 memset(&temp_misc.shop, 0, sizeof(shoptype)*256);
5411 205824 }
5412
5413
2/2
✓ Branch 0 taken 205824 times.
✓ Branch 1 taken 804 times.
206628 for(int32_t i=0; i<maxinfos; ++i)
5414 {
5415 205824 memset(&temp_misc.info, 0, sizeof(infotype)*256);
5416 205824 }
5417
5418 804 memset(&temp_misc.warp, 0, sizeof(temp_misc.warp));
5419
5420
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 780 times.
804 if(Header->zelda_version > 0x192)
5421 {
5422 //section version info
5423
1/2
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
780 if(!p_igetw(&s_version,f))
5424 {
5425 return qe_invalid;
5426 }
5427
5428 780 FFCore.quest_format[vMisc] = s_version;
5429
5430
1/2
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
780 if(!read_deprecated_section_cversion(f))
5431 {
5432 return qe_invalid;
5433 }
5434
5435
5436 //section size
5437
1/2
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
780 if(!p_igetl(&tempsize,f))
5438 {
5439 return qe_invalid;
5440 }
5441 780 }
5442
5443 //finally... section data
5444 804 readsize=0;
5445
5446 //shops
5447
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 780 times.
804 if(Header->zelda_version > 0x192)
5448 {
5449
1/2
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
780 if(!p_igetw(&shops,f))
5450 {
5451 return qe_invalid;
5452 }
5453 780 }
5454
5455
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 804 times.
804 if (shops > NUM_SHOPS)
5456 {
5457 return qe_invalid;
5458 }
5459
5460
2/2
✓ Branch 0 taken 11070 times.
✓ Branch 1 taken 804 times.
11874 for(int32_t i=0; i<shops; i++)
5461 {
5462
2/2
✓ Branch 0 taken 1200 times.
✓ Branch 1 taken 9870 times.
11070 if(s_version > 6)
5463 {
5464
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9870 times.
9870 if(!p_getstr(temp_misc.shop[i].name,sizeof(temp_misc.shop[i].name)-1,f))
5465 {
5466 return qe_invalid;
5467 }
5468 9870 }
5469
5470
2/2
✓ Branch 0 taken 33210 times.
✓ Branch 1 taken 11070 times.
44280 for(int32_t j=0; j<3; j++)
5471 {
5472
1/2
✓ Branch 0 taken 33210 times.
✗ Branch 1 not taken.
33210 if(!p_getc(&temp_misc.shop[i].item[j],f))
5473 {
5474 return qe_invalid;
5475 }
5476
5477
2/2
✓ Branch 0 taken 29610 times.
✓ Branch 1 taken 3600 times.
33210 if(s_version < 4)
5478 {
5479 3600 temp_misc.shop[i].hasitem[j] = (temp_misc.shop[i].item[j] == 0) ? 0 : 1;
5480 3600 }
5481 33210 }
5482
5483
2/2
✓ Branch 0 taken 10686 times.
✓ Branch 1 taken 384 times.
11070 if(Header->zelda_version < 0x193)
5484 {
5485
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 384 times.
384 if(!p_getc(&tempbyte,f))
5486 {
5487 return qe_invalid;
5488 }
5489 384 }
5490
5491
2/2
✓ Branch 0 taken 33210 times.
✓ Branch 1 taken 11070 times.
44280 for(int32_t j=0; j<3; j++)
5492 {
5493
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33210 times.
33210 if(!p_igetw(&temp_misc.shop[i].price[j],f))
5494 {
5495 return qe_invalid;
5496 }
5497 33210 }
5498
5499
2/2
✓ Branch 0 taken 1200 times.
✓ Branch 1 taken 9870 times.
11070 if(s_version > 3)
5500 {
5501
2/2
✓ Branch 0 taken 29610 times.
✓ Branch 1 taken 9870 times.
39480 for(int32_t j=0; j<3; j++)
5502 {
5503
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29610 times.
29610 if(!p_getc(&temp_misc.shop[i].hasitem[j],f))
5504 return qe_invalid;
5505 29610 }
5506 9870 }
5507
5508 /*
5509 if(s_version < 8)
5510 {
5511 for(int32_t j=0; j<3; j++)
5512 {
5513 (&temp_misc.shop[i].str[j])=0; //initialise.
5514 }
5515 }
5516 */
5517 11070 }
5518
5519 //filter all the 0 items to the end (yeah, bubble sort; sue me)
5520
2/2
✓ Branch 0 taken 205824 times.
✓ Branch 1 taken 804 times.
206628 for(int32_t i=0; i<maxshops; ++i)
5521 {
5522
2/2
✓ Branch 0 taken 411648 times.
✓ Branch 1 taken 205824 times.
617472 for(int32_t j=0; j<3-1; j++)
5523 {
5524
2/2
✓ Branch 0 taken 617472 times.
✓ Branch 1 taken 411648 times.
1029120 for(int32_t k=0; k<2-j; k++)
5525 {
5526
2/2
✓ Branch 0 taken 23904 times.
✓ Branch 1 taken 593568 times.
617472 if(temp_misc.shop[i].hasitem[k]==0)
5527 {
5528 593568 swaptmp = temp_misc.shop[i].item[k];
5529 593568 temp_misc.shop[i].item[k] = temp_misc.shop[i].item[k+1];
5530 593568 temp_misc.shop[i].item[k+1] = swaptmp;
5531 593568 swaptmp = temp_misc.shop[i].price[k];
5532 593568 temp_misc.shop[i].price[k] = temp_misc.shop[i].price[k+1];
5533 593568 temp_misc.shop[i].price[k+1] = swaptmp;
5534 593568 swaptmp = temp_misc.shop[i].hasitem[k];
5535 593568 temp_misc.shop[i].hasitem[k] = temp_misc.shop[i].hasitem[k+1];
5536 593568 temp_misc.shop[i].hasitem[k+1] = swaptmp;
5537 593568 }
5538 617472 }
5539 411648 }
5540 205824 }
5541
5542 //infos
5543
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 780 times.
804 if(Header->zelda_version > 0x192)
5544 {
5545
1/2
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
780 if(!p_igetw(&infos,f))
5546 {
5547 return qe_invalid;
5548 }
5549 780 }
5550
5551
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 804 times.
804 if (infos > NUM_INFOS)
5552 {
5553 return qe_invalid;
5554 }
5555
5556
5557
2/2
✓ Branch 0 taken 10376 times.
✓ Branch 1 taken 804 times.
11180 for(int32_t i=0; i<infos; i++)
5558 {
5559
2/2
✓ Branch 0 taken 761 times.
✓ Branch 1 taken 9615 times.
10376 if(s_version > 6)
5560 {
5561
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9615 times.
9615 if(!p_getstr(temp_misc.info[i].name,sizeof(temp_misc.info[i].name)-1,f))
5562 {
5563 return qe_invalid;
5564 }
5565 9615 }
5566
5567
2/2
✓ Branch 0 taken 31128 times.
✓ Branch 1 taken 10376 times.
41504 for(int32_t j=0; j<3; j++)
5568 {
5569
3/4
✓ Branch 0 taken 30264 times.
✓ Branch 1 taken 864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 288 times.
31416 if((Header->zelda_version < 0x192)||
5570
2/2
✓ Branch 0 taken 288 times.
✓ Branch 1 taken 29976 times.
30264 ((Header->zelda_version == 0x192)&&(Header->build<146)))
5571 {
5572
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 864 times.
864 if(!p_getc(&tempbyte,f))
5573 {
5574 return qe_invalid;
5575 }
5576
5577 864 temp_misc.info[i].str[j]=tempbyte;
5578 864 }
5579 else
5580 {
5581
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30264 times.
30264 if(!p_igetw(&temp_misc.info[i].str[j],f))
5582 {
5583 return qe_invalid;
5584 }
5585 }
5586 31128 }
5587
5588
2/2
✓ Branch 0 taken 9992 times.
✓ Branch 1 taken 384 times.
10376 if(Header->zelda_version < 0x193)
5589 {
5590
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!p_getc(&tempbyte,f))
5591 {
5592 return qe_invalid;
5593 }
5594 384 }
5595
5596
3/4
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 10280 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 96 times.
10376 if((Header->zelda_version == 0x192)&&(Header->build>145))
5597 {
5598
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&padding,f))
5599 {
5600 return qe_invalid;
5601 }
5602 96 }
5603
5604
2/2
✓ Branch 0 taken 31128 times.
✓ Branch 1 taken 10376 times.
41504 for(int32_t j=0; j<3; j++)
5605 {
5606
1/2
✓ Branch 0 taken 31128 times.
✗ Branch 1 not taken.
31128 if(!p_igetw(&temp_misc.info[i].price[j],f))
5607 {
5608 return qe_invalid;
5609 }
5610 31128 }
5611 10376 }
5612
5613 //filter all the 0 strings to the end (yeah, bubble sort; sue me)
5614
2/2
✓ Branch 0 taken 205824 times.
✓ Branch 1 taken 804 times.
206628 for(int32_t i=0; i<maxinfos; ++i)
5615 {
5616
2/2
✓ Branch 0 taken 411648 times.
✓ Branch 1 taken 205824 times.
617472 for(int32_t j=0; j<3-1; j++)
5617 {
5618
2/2
✓ Branch 0 taken 617472 times.
✓ Branch 1 taken 411648 times.
1029120 for(int32_t k=0; k<2-j; k++)
5619 {
5620
2/2
✓ Branch 0 taken 11752 times.
✓ Branch 1 taken 605720 times.
617472 if(temp_misc.info[i].str[k]==0)
5621 {
5622 605720 swaptmp = temp_misc.info[i].str[k];
5623 605720 temp_misc.info[i].str[k] = temp_misc.info[i].str[k+1];
5624 605720 temp_misc.info[i].str[k+1] = swaptmp;
5625 605720 swaptmp = temp_misc.info[i].price[k];
5626 605720 temp_misc.info[i].price[k] = temp_misc.info[i].price[k+1];
5627 605720 temp_misc.info[i].price[k+1] = swaptmp;
5628 605720 }
5629 617472 }
5630 411648 }
5631 205824 }
5632
5633
5634 //warp rings
5635
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 721 times.
804 if(s_version > 5)
5636 721 warprings++;
5637
5638
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 780 times.
804 if(Header->zelda_version > 0x192)
5639 {
5640
1/2
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
780 if(!p_igetw(&warprings,f))
5641 {
5642 return qe_invalid;
5643 }
5644
5645
2/2
✓ Branch 0 taken 340 times.
✓ Branch 1 taken 440 times.
780 if (warprings > NUM_WARP_RINGS)
5646 {
5647 // return qe_invalid;
5648 // Note: we can't actually fail here because for some reason, some quest files have more than the max
5649 // number of possible warp rings. Some examples of this are: demosp253.qst, yuurand.qst
5650 // So instead below we disable `keepdata` when reading the bad warp ring data, so no memory is corrupted.
5651 440 }
5652 780 }
5653
5654
2/2
✓ Branch 0 taken 8404 times.
✓ Branch 1 taken 804 times.
9208 for(int32_t i=0; i<warprings; i++)
5655 {
5656 // See above comment on the `warprings` range check.
5657 8404 bool keepdata = i < NUM_WARP_RINGS;
5658
5659
2/2
✓ Branch 0 taken 74516 times.
✓ Branch 1 taken 8404 times.
82920 for(int32_t j=0; j<8+((s_version > 5)?1:0); j++)
5660 {
5661
2/2
✓ Branch 0 taken 8960 times.
✓ Branch 1 taken 65556 times.
74516 if(s_version <= 3)
5662 {
5663
1/2
✓ Branch 0 taken 8960 times.
✗ Branch 1 not taken.
8960 if(!p_getc(&tempbyte,f))
5664 {
5665 return qe_invalid;
5666 }
5667
5668
2/2
✓ Branch 0 taken 3192 times.
✓ Branch 1 taken 5768 times.
8960 if (keepdata)
5669 5768 temp_misc.warp[i].dmap[j]=(word)tempbyte;
5670 8960 }
5671 else
5672 {
5673 word tempword;
5674
1/2
✓ Branch 0 taken 65556 times.
✗ Branch 1 not taken.
65556 if(!p_igetw(&tempword,f))
5675 {
5676 return qe_invalid;
5677 }
5678
5679
2/2
✓ Branch 0 taken 7461 times.
✓ Branch 1 taken 58095 times.
65556 if (keepdata)
5680 58095 temp_misc.warp[i].dmap[j] = tempword;
5681 }
5682 74516 }
5683
5684
2/2
✓ Branch 0 taken 74516 times.
✓ Branch 1 taken 8404 times.
82920 for(int32_t j=0; j<8+((s_version > 5)?1:0); j++)
5685 {
5686
1/2
✓ Branch 0 taken 74516 times.
✗ Branch 1 not taken.
74516 if(!p_getc(&tempbyte,f))
5687 {
5688 return qe_invalid;
5689 }
5690
2/2
✓ Branch 0 taken 10653 times.
✓ Branch 1 taken 63863 times.
74516 if (keepdata)
5691 63863 temp_misc.warp[i].scr[j] = tempbyte;
5692 74516 }
5693
5694
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8404 times.
8404 if(!p_getc(&tempbyte,f))
5695 {
5696 return qe_invalid;
5697 }
5698
2/2
✓ Branch 0 taken 1228 times.
✓ Branch 1 taken 7176 times.
8404 if (keepdata)
5699 7176 temp_misc.warp[i].size = tempbyte;
5700
5701
2/2
✓ Branch 0 taken 8212 times.
✓ Branch 1 taken 192 times.
8404 if(Header->zelda_version < 0x193)
5702 {
5703
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if(!p_getc(&tempbyte,f))
5704 {
5705 return qe_invalid;
5706 }
5707 192 }
5708 8404 }
5709
5710 //palette cycles
5711
2/2
✓ Branch 0 taken 780 times.
✓ Branch 1 taken 24 times.
804 if(Header->zelda_version < 0x193) //in 1.93+, palette cycling is saved with the palettes
5712 {
5713
2/2
✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 24 times.
6168 for(int32_t i=0; i<256; i++)
5714 {
5715
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 6144 times.
24576 for(int32_t j=0; j<3; j++)
5716 {
5717 18432 temp_misc.cycles[i][j].first=0;
5718 18432 temp_misc.cycles[i][j].count=0;
5719 18432 temp_misc.cycles[i][j].speed=0;
5720 18432 }
5721 6144 }
5722
5723
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
30 if((Header->zelda_version < 0x192)||
5724
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((Header->zelda_version == 0x192)&&(Header->build<73)))
5725 {
5726 18 palcycles=16;
5727 18 }
5728
5729
2/2
✓ Branch 0 taken 1824 times.
✓ Branch 1 taken 24 times.
1848 for(int32_t i=0; i<palcycles; i++)
5730 {
5731
2/2
✓ Branch 0 taken 5472 times.
✓ Branch 1 taken 1824 times.
7296 for(int32_t j=0; j<3; j++)
5732 {
5733
1/2
✓ Branch 0 taken 5472 times.
✗ Branch 1 not taken.
5472 if(!p_getc(&temp_misc.cycles[i][j].first,f))
5734 {
5735 return qe_invalid;
5736 }
5737
5738
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5472 times.
5472 if(!p_getc(&temp_misc.cycles[i][j].count,f))
5739 {
5740 return qe_invalid;
5741 }
5742
5743
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5472 times.
5472 if(!p_getc(&temp_misc.cycles[i][j].speed,f))
5744 {
5745 return qe_invalid;
5746 }
5747 5472 }
5748 1824 }
5749 24 }
5750
5751 //Wind warps are now just another warp ring.
5752
2/2
✓ Branch 0 taken 721 times.
✓ Branch 1 taken 83 times.
804 if(s_version <= 5)
5753 {
5754
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 59 times.
83 if(Header->zelda_version > 0x192)
5755 {
5756
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 if(!p_igetw(&windwarps,f))
5757 {
5758 return qe_invalid;
5759 }
5760 59 }
5761
5762
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 83 times.
83 if (windwarps > NUM_WARP_RINGS)
5763 {
5764 return qe_invalid;
5765 }
5766
5767
2/2
✓ Branch 0 taken 665 times.
✓ Branch 1 taken 83 times.
748 for(int32_t i=0; i<windwarps; i++)
5768 {
5769
1/2
✓ Branch 0 taken 665 times.
✗ Branch 1 not taken.
665 if(s_version <= 3)
5770 {
5771
1/2
✓ Branch 0 taken 665 times.
✗ Branch 1 not taken.
665 if(!p_getc(&tempbyte,f))
5772 {
5773 return qe_invalid;
5774 }
5775
5776 665 temp_misc.warp[8].dmap[i]=tempbyte;
5777 665 }
5778 else
5779 {
5780 if(!p_igetw(&temp_misc.warp[8].dmap[i],f))
5781 {
5782 return qe_invalid;
5783 }
5784 }
5785
5786
1/2
✓ Branch 0 taken 665 times.
✗ Branch 1 not taken.
665 if(!p_getc(&temp_misc.warp[8].scr[i],f))
5787 {
5788 return qe_invalid;
5789 }
5790
5791 665 temp_misc.warp[8].size = 9;
5792
5793
1/2
✓ Branch 0 taken 665 times.
✗ Branch 1 not taken.
665 if(s_version == 5)
5794 {
5795 if(!p_getc(&tempbyte,f))
5796 {
5797 return qe_invalid;
5798 }
5799 }
5800 665 }
5801 83 }
5802
5803
5804 //triforce pieces
5805
2/2
✓ Branch 0 taken 6432 times.
✓ Branch 1 taken 804 times.
7236 for(int32_t i=0; i<triforces; i++)
5806 {
5807
1/2
✓ Branch 0 taken 6432 times.
✗ Branch 1 not taken.
6432 if(!p_getc(&temp_misc.triforce[i],f))
5808 {
5809 return qe_invalid;
5810 }
5811 6432 }
5812
5813 //misc color data
5814
2/2
✓ Branch 0 taken 721 times.
✓ Branch 1 taken 83 times.
804 if(s_version<3)
5815 {
5816
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.text,f))
5817 {
5818 return qe_invalid;
5819 }
5820
5821
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.caption,f))
5822 {
5823 return qe_invalid;
5824 }
5825
5826
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.overw_bg,f))
5827 {
5828 return qe_invalid;
5829 }
5830
5831
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.dngn_bg,f))
5832 {
5833 return qe_invalid;
5834 }
5835
5836
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.dngn_fg,f))
5837 {
5838 return qe_invalid;
5839 }
5840
5841
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.cave_fg,f))
5842 {
5843 return qe_invalid;
5844 }
5845
5846
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.bs_dk,f))
5847 {
5848 return qe_invalid;
5849 }
5850
5851
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.bs_goal,f))
5852 {
5853 return qe_invalid;
5854 }
5855
5856
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.compass_lt,f))
5857 {
5858 return qe_invalid;
5859 }
5860
5861
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.compass_dk,f))
5862 {
5863 return qe_invalid;
5864 }
5865
5866
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.subscr_bg,f))
5867 {
5868 return qe_invalid;
5869 }
5870
5871
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.triframe_color,f))
5872 {
5873 return qe_invalid;
5874 }
5875
5876
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.hero_dot,f))
5877 {
5878 return qe_invalid;
5879 }
5880
5881
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.bmap_bg,f))
5882 {
5883 return qe_invalid;
5884 }
5885
5886
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.bmap_fg,f))
5887 {
5888 return qe_invalid;
5889 }
5890
5891
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.triforce_cset,f))
5892 {
5893 return qe_invalid;
5894 }
5895
5896
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.triframe_cset,f))
5897 {
5898 return qe_invalid;
5899 }
5900
5901
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.overworld_map_cset,f))
5902 {
5903 return qe_invalid;
5904 }
5905
5906
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.dungeon_map_cset,f))
5907 {
5908 return qe_invalid;
5909 }
5910
5911
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.blueframe_cset,f))
5912 {
5913 return qe_invalid;
5914 }
5915
5916
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_igetw(&temp_misc.colors.triforce_tile,f))
5917 {
5918 return qe_invalid;
5919 }
5920
5921
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_igetw(&temp_misc.colors.triframe_tile,f))
5922 {
5923 return qe_invalid;
5924 }
5925
5926
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_igetw(&temp_misc.colors.overworld_map_tile,f))
5927 {
5928 return qe_invalid;
5929 }
5930
5931
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_igetw(&temp_misc.colors.dungeon_map_tile,f))
5932 {
5933 return qe_invalid;
5934 }
5935
5936
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_igetw(&temp_misc.colors.blueframe_tile,f))
5937 {
5938 return qe_invalid;
5939 }
5940
5941
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_igetw(&temp_misc.colors.HCpieces_tile,f))
5942 {
5943 return qe_invalid;
5944 }
5945
5946
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.HCpieces_cset,f))
5947 {
5948 return qe_invalid;
5949 }
5950
5951 83 temp_misc.colors.msgtext = 0x01;
5952
5953
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 24 times.
83 if(Header->zelda_version < 0x193)
5954 {
5955
2/2
✓ Branch 0 taken 168 times.
✓ Branch 1 taken 24 times.
192 for(int32_t i=0; i<7; i++)
5956 {
5957
1/2
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
168 if(!p_getc(&tempbyte,f))
5958 {
5959 return qe_invalid;
5960 }
5961 168 }
5962 24 }
5963
5964
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 77 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
83 if((Header->zelda_version == 0x192)&&(Header->build>145))
5965 {
5966
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 6 times.
1542 for(int32_t i=0; i<256; i++)
5967 {
5968
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1536 times.
1536 if(!p_getc(&tempbyte,f))
5969 {
5970 return qe_invalid;
5971 }
5972 1536 }
5973 6 }
5974
5975
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(s_version>1)
5976 {
5977 if(!p_getc(&temp_misc.colors.subscr_shadow,f))
5978 {
5979 return qe_invalid;
5980 }
5981 }
5982
5983 //save game icons
5984
3/4
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
89 if((Header->zelda_version < 0x192)||
5985
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 59 times.
65 ((Header->zelda_version == 0x192)&&(Header->build<73)))
5986 {
5987 18 icons=3;
5988 18 }
5989
5990
2/2
✓ Branch 0 taken 314 times.
✓ Branch 1 taken 83 times.
397 for(int32_t i=0; i<icons; i++)
5991 {
5992
1/2
✓ Branch 0 taken 314 times.
✗ Branch 1 not taken.
314 if(!p_igetw(&temp_misc.icons[i],f))
5993 {
5994 return qe_invalid;
5995 }
5996 314 }
5997 83 }
5998
5999
3/4
✓ Branch 0 taken 786 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
810 if((Header->zelda_version < 0x192)||
6000
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 780 times.
786 ((Header->zelda_version == 0x192)&&(Header->build<30)))
6001 {
6002 18 memcpy(Misc, &temp_misc, sizeof(temp_misc));
6003
6004 18 return 0;
6005 }
6006
6007 //pond information
6008
2/2
✓ Branch 0 taken 780 times.
✓ Branch 1 taken 6 times.
786 if(Header->zelda_version < 0x193)
6009 {
6010
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if((Header->zelda_version == 0x192)&&(Header->build<146))
6011 {
6012 pondsize=25;
6013 }
6014
6015
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 6 times.
102 for(int32_t i=0; i<ponds; i++)
6016 {
6017
2/2
✓ Branch 0 taken 6912 times.
✓ Branch 1 taken 96 times.
7008 for(int32_t j=0; j<pondsize; j++)
6018 {
6019
1/2
✓ Branch 0 taken 6912 times.
✗ Branch 1 not taken.
6912 if(!p_getc(&tempbyte,f))
6020 {
6021 return qe_invalid;
6022
6023 }
6024 6912 }
6025 96 }
6026 6 }
6027
6028 //end string
6029
2/4
✓ Branch 0 taken 786 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
792 if((Header->zelda_version < 0x192)||
6030
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 780 times.
786 ((Header->zelda_version == 0x192)&&(Header->build<146)))
6031 {
6032 if(!p_getc(&tempbyte,f))
6033 {
6034 return qe_invalid;
6035 }
6036
6037 temp_misc.endstring=tempbyte;
6038
6039 if(!p_getc(&tempbyte,f))
6040 {
6041 return qe_invalid;
6042 }
6043 }
6044 else
6045 {
6046
1/2
✓ Branch 0 taken 786 times.
✗ Branch 1 not taken.
786 if(!p_igetw(&temp_misc.endstring,f))
6047 {
6048 return qe_invalid;
6049 }
6050 }
6051
6052 //expansion
6053
2/2
✓ Branch 0 taken 780 times.
✓ Branch 1 taken 6 times.
786 if(Header->zelda_version < 0x193)
6054 {
6055
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if((Header->zelda_version == 0x192)&&(Header->build<73))
6056 {
6057 expansionsize=99*2;
6058 }
6059
6060
2/2
✓ Branch 0 taken 1176 times.
✓ Branch 1 taken 6 times.
1182 for(int32_t i=0; i<expansionsize; i++)
6061 {
6062
1/2
✓ Branch 0 taken 1176 times.
✗ Branch 1 not taken.
1176 if(!p_getc(&tempbyte,f))
6063 {
6064 return qe_invalid;
6065 }
6066 1176 }
6067 6 }
6068 //shops v8
6069
6070
6071
2/2
✓ Branch 0 taken 594 times.
✓ Branch 1 taken 192 times.
786 if(s_version >= 8)
6072 {
6073
2/2
✓ Branch 0 taken 2320 times.
✓ Branch 1 taken 192 times.
2512 for(int32_t i=0; i<shops; i++)
6074 {
6075
2/2
✓ Branch 0 taken 6960 times.
✓ Branch 1 taken 2320 times.
9280 for(int32_t j=0; j<3; j++)
6076 {
6077
1/2
✓ Branch 0 taken 6960 times.
✗ Branch 1 not taken.
6960 if(!p_igetw(&temp_misc.shop[i].str[j],f))
6078 return qe_invalid;
6079 6960 }
6080 2320 }
6081 192 }
6082
6083 786 memset(&temp_misc.questmisc, 0, sizeof(int32_t)*32);
6084 786 memset(&temp_misc.zscript_last_compiled_version, 0, sizeof(int32_t));
6085
6086 //v9 includes quest misc[32]
6087 // ... this has been deprecated (2024)
6088
2/2
✓ Branch 0 taken 594 times.
✓ Branch 1 taken 192 times.
786 if(s_version >= 9)
6089 {
6090
2/2
✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 192 times.
6336 for ( int32_t q = 0; q < 32; q++ )
6091 {
6092
1/2
✓ Branch 0 taken 6144 times.
✗ Branch 1 not taken.
6144 if(!p_igetl(&temp_misc.questmisc[q],f))
6093 return qe_invalid;
6094 6144 }
6095 // this was string labels
6096
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if (pack_fseek(f, 32 * 128))
6097 return qe_invalid;
6098 192 }
6099
6100
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 594 times.
786 if(s_version >= 11 )
6101 {
6102
1/2
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
192 if(!p_igetl(&temp_misc.zscript_last_compiled_version,f))
6103 return qe_invalid;
6104 192 }
6105
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 594 times.
594 else if(s_version < 11 )
6106 {
6107 594 temp_misc.zscript_last_compiled_version = -1;
6108 594 }
6109
6110 786 FFCore.quest_format[vLastCompile] = temp_misc.zscript_last_compiled_version;
6111
6112
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 594 times.
786 if(s_version >= 12)
6113 {
6114 byte spr;
6115
2/2
✓ Branch 0 taken 49152 times.
✓ Branch 1 taken 192 times.
49344 for(int32_t q = 0; q < sprMAX; ++q)
6116 {
6117
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_getc(&spr,f))
6118 return qe_invalid;
6119 49152 temp_misc.sprites[q] = spr;
6120 49152 }
6121 192 }
6122 else
6123 {
6124 594 memset(&(temp_misc.sprites), 0, sizeof(temp_misc.sprites));
6125 //temp_misc.sprites[sprFALL] = ;
6126 }
6127
6128
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 594 times.
786 if(s_version >= 13)
6129 {
6130
2/2
✓ Branch 0 taken 12288 times.
✓ Branch 1 taken 192 times.
12480 for(size_t q = 0; q < 64; ++q)
6131 {
6132 12288 bottletype* bt = &(temp_misc.bottle_types[q]);
6133
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if (!p_getstr(bt->name, sizeof(bt->name)-1, f))
6134 return qe_invalid;
6135
2/2
✓ Branch 0 taken 36864 times.
✓ Branch 1 taken 12288 times.
49152 for(size_t j = 0; j < 3; ++j)
6136 {
6137
1/2
✓ Branch 0 taken 36864 times.
✗ Branch 1 not taken.
36864 if (!p_getc(&(bt->counter[j]), f))
6138 return qe_invalid;
6139
1/2
✓ Branch 0 taken 36864 times.
✗ Branch 1 not taken.
36864 if (!p_igetw(&(bt->amount[j]), f))
6140 return qe_invalid;
6141 36864 }
6142
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if (!p_getc(&(bt->flags), f))
6143 return qe_invalid;
6144
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if (!p_getc(&(bt->next_type), f))
6145 return qe_invalid;
6146 12288 }
6147
2/2
✓ Branch 0 taken 49152 times.
✓ Branch 1 taken 192 times.
49344 for(size_t q = 0; q < 256; ++q)
6148 {
6149 49152 bottleshoptype* bst = &(temp_misc.bottle_shop_types[q]);
6150
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if (!pfread(bst->name, sizeof(bst->name)-1, f))
6151 return qe_invalid;
6152
2/2
✓ Branch 0 taken 147456 times.
✓ Branch 1 taken 49152 times.
196608 for(size_t j = 0; j < 3; ++j)
6153 {
6154
1/2
✓ Branch 0 taken 147456 times.
✗ Branch 1 not taken.
147456 if (!p_getc(&(bst->fill[j]), f))
6155 return qe_invalid;
6156
1/2
✓ Branch 0 taken 147456 times.
✗ Branch 1 not taken.
147456 if (!p_igetw(&(bst->comb[j]), f))
6157 return qe_invalid;
6158
1/2
✓ Branch 0 taken 147456 times.
✗ Branch 1 not taken.
147456 if (!p_getc(&(bst->cset[j]), f))
6159 return qe_invalid;
6160
1/2
✓ Branch 0 taken 147456 times.
✗ Branch 1 not taken.
147456 if (!p_igetw(&(bst->price[j]), f))
6161 return qe_invalid;
6162
1/2
✓ Branch 0 taken 147456 times.
✗ Branch 1 not taken.
147456 if (!p_igetw(&(bst->str[j]), f))
6163 return qe_invalid;
6164 147456 }
6165 49152 }
6166 192 }
6167 else
6168 {
6169
2/2
✓ Branch 0 taken 38016 times.
✓ Branch 1 taken 594 times.
38610 for(size_t q = 0; q < 64; ++q)
6170 38016 temp_misc.bottle_types[q].clear();
6171
2/2
✓ Branch 0 taken 152064 times.
✓ Branch 1 taken 594 times.
152658 for(size_t q = 0; q < 256; ++q)
6172 152064 temp_misc.bottle_shop_types[q].clear();
6173 }
6174
6175
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 594 times.
786 if(s_version >= 14)
6176 {
6177 byte msfx;
6178
2/2
✓ Branch 0 taken 49152 times.
✓ Branch 1 taken 192 times.
49344 for(int32_t q = 0; q < sfxMAX; ++q)
6179 {
6180
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_getc(&msfx,f))
6181 return qe_invalid;
6182 49152 temp_misc.miscsfx[q] = msfx;
6183 49152 }
6184 192 }
6185 else
6186 {
6187 594 memset(&(temp_misc.miscsfx), 0, sizeof(temp_misc.miscsfx));
6188 594 temp_misc.miscsfx[sfxBUSHGRASS] = WAV_ZN1GRASSCUT;
6189 594 temp_misc.miscsfx[sfxLOWHEART] = WAV_ER;
6190 }
6191
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 594 times.
786 if(s_version < 15)
6192 {
6193 594 temp_misc.miscsfx[sfxHURTPLAYER] = WAV_OUCH;
6194 594 temp_misc.miscsfx[sfxHAMMERPOUND] = WAV_ZN1HAMMERPOST;
6195 594 temp_misc.miscsfx[sfxSUBSCR_ITEM_ASSIGN] = WAV_PLACE;
6196 594 temp_misc.miscsfx[sfxSUBSCR_CURSOR_MOVE] = WAV_CHIME;
6197 594 temp_misc.miscsfx[sfxREFILL] = WAV_MSG;
6198 594 temp_misc.miscsfx[sfxDRAIN] = WAV_MSG;
6199 594 }
6200
2/2
✓ Branch 0 taken 175 times.
✓ Branch 1 taken 611 times.
786 if(s_version < 16)
6201 {
6202 611 temp_misc.miscsfx[sfxTAP] = WAV_ZN1TAP;
6203 611 temp_misc.miscsfx[sfxTAP_HOLLOW] = WAV_ZN1TAP2;
6204 611 }
6205
6206
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 785 times.
786 if (!should_skip)
6207 785 memcpy(Misc, &temp_misc, sizeof(temp_misc));
6208
6209 786 return 0;
6210 804 }
6211
6212 extern char *item_string[MAXITEMS];
6213 extern const char *old_item_string[iLast];
6214 extern char *weapon_string[MAXWPNS];
6215 extern const char *old_weapon_string[wLast];
6216
6217 481 int32_t readitems(PACKFILE *f, word version, word build)
6218 {
6219
2/2
✓ Branch 0 taken 457 times.
✓ Branch 1 taken 24 times.
481 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_items);
6220
6221 byte padding;
6222 int32_t dummy;
6223 481 word items_to_read=MAXITEMS;
6224 481 itemdata tempitem;
6225 481 word s_version=0;
6226 word dummy_word;
6227
6228
2/2
✓ Branch 0 taken 475 times.
✓ Branch 1 taken 6 times.
481 if(version < 0x186)
6229 {
6230 6 items_to_read=64;
6231 6 }
6232
6233
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 457 times.
481 if(version > 0x192)
6234 {
6235 457 items_to_read=0;
6236
6237 //section version info
6238
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 if(!p_igetw(&s_version,f))
6239 {
6240 return qe_invalid;
6241 }
6242
6243 457 FFCore.quest_format[vItems] = s_version;
6244
6245
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 if(!read_deprecated_section_cversion(f))
6246 {
6247 return qe_invalid;
6248 }
6249
6250 //section size
6251
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 if(!p_igetl(&dummy,f))
6252 {
6253 return qe_invalid;
6254 }
6255
6256 //finally... section data
6257
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 if(!p_igetw(&items_to_read,f))
6258 {
6259 return qe_invalid;
6260 }
6261
6262
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
457 if (items_to_read > MAXITEMS)
6263 {
6264 return qe_invalid;
6265 }
6266 457 }
6267
6268
2/2
✓ Branch 0 taken 398 times.
✓ Branch 1 taken 83 times.
481 if(s_version>1)
6269 {
6270
2/2
✓ Branch 0 taken 101888 times.
✓ Branch 1 taken 398 times.
102286 for(int32_t i=0; i<items_to_read; i++)
6271 {
6272 char tempname[64];
6273
6274
1/2
✓ Branch 0 taken 101888 times.
✗ Branch 1 not taken.
101888 if(!pfread(tempname, 64, f))
6275 {
6276 return qe_invalid;
6277 }
6278
6279 101888 item_string[i][0] = '\0';
6280 101888 strncat(item_string[i], tempname, 64 - 1);
6281 101888 }
6282 398 }
6283
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 82 times.
83 else if (!should_skip)
6284 {
6285
2/2
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 82 times.
21074 for(int32_t i=0; i<MAXITEMS; i++)
6286 {
6287 20992 reset_itemname(i);
6288 20992 }
6289 82 }
6290
6291
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 480 times.
481 if (!should_skip)
6292
2/2
✓ Branch 0 taken 122880 times.
✓ Branch 1 taken 480 times.
123360 for(int32_t i=0; i<MAXITEMS; i++)
6293 {
6294 122880 itemdata& id = itemsbuf[i];
6295 122880 memset(&id, 0, sizeof(itemdata));
6296 122880 id.count=-1;
6297 122880 id.playsound=WAV_SCALE;
6298 122880 reset_itembuf(&id,i);
6299 123360 }
6300
6301
2/2
✓ Branch 0 taken 111010 times.
✓ Branch 1 taken 481 times.
111491 for(int32_t i=0; i<items_to_read; i++)
6302 {
6303 111010 tempitem = itemdata();
6304 111010 reset_itembuf(&tempitem,i);
6305
6306
2/2
✓ Branch 0 taken 49152 times.
✓ Branch 1 taken 61858 times.
111010 if ( s_version > 35 ) //expanded tiles
6307 {
6308
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetl(&tempitem.tile,f))
6309 {
6310 return qe_invalid;
6311 }
6312 49152 }
6313 else
6314 {
6315
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 61858 times.
61858 if(!p_igetw(&tempitem.tile,f))
6316 {
6317 return qe_invalid;
6318 }
6319 }
6320
6321
1/2
✓ Branch 0 taken 111010 times.
✗ Branch 1 not taken.
111010 if(!p_getc(&tempitem.misc_flags,f))
6322 {
6323 return qe_invalid;
6324 }
6325
6326
1/2
✓ Branch 0 taken 111010 times.
✗ Branch 1 not taken.
111010 if(!p_getc(&tempitem.csets,f))
6327 {
6328 return qe_invalid;
6329 }
6330
6331
1/2
✓ Branch 0 taken 111010 times.
✗ Branch 1 not taken.
111010 if(!p_getc(&tempitem.frames,f))
6332 {
6333 return qe_invalid;
6334 }
6335
6336
1/2
✓ Branch 0 taken 111010 times.
✗ Branch 1 not taken.
111010 if(!p_getc(&tempitem.speed,f))
6337 {
6338 return qe_invalid;
6339 }
6340
6341
1/2
✓ Branch 0 taken 111010 times.
✗ Branch 1 not taken.
111010 if(!p_getc(&tempitem.delay,f))
6342 {
6343 return qe_invalid;
6344 }
6345
6346
2/2
✓ Branch 0 taken 106018 times.
✓ Branch 1 taken 4992 times.
111010 if(version < 0x193)
6347 {
6348
1/2
✓ Branch 0 taken 4992 times.
✗ Branch 1 not taken.
4992 if(!p_getc(&padding,f))
6349 {
6350 return qe_invalid;
6351 }
6352
6353
4/6
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 3456 times.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1536 times.
✗ Branch 5 not taken.
4992 if((version < 0x192)||((version == 0x192)&&(build<186)))
6354 {
6355
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 4736 times.
4992 if (should_skip)
6356 256 continue;
6357
6358
3/3
✓ Branch 0 taken 4690 times.
✓ Branch 1 taken 23 times.
✓ Branch 2 taken 23 times.
4736 switch(i)
6359 {
6360 case iShield:
6361 23 tempitem.ltm=get_qr(qr_BSZELDA)?-12:10;
6362 23 break;
6363
6364 case iMShield:
6365 23 tempitem.ltm=get_qr(qr_BSZELDA)?-6:-10;
6366 23 break;
6367
6368 default:
6369 4690 tempitem.ltm=0;
6370 4690 break;
6371 }
6372
6373 4736 tempitem.count=-1;
6374 4736 tempitem.flags=item_none;
6375 4736 tempitem.wpn=tempitem.wpn2=tempitem.wpn3=tempitem.wpn3=tempitem.pickup_hearts=
6376 4736 tempitem.misc1=tempitem.misc2=tempitem.usesound=0;
6377 4736 tempitem.family=0xFF;
6378 4736 tempitem.playsound=WAV_SCALE;
6379 4736 reset_itembuf(&tempitem,i);
6380
6381 4736 itemsbuf[i] = tempitem;
6382
6383 4736 continue;
6384 }
6385 }
6386
6387
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106018 times.
106018 if(!p_igetl(&tempitem.ltm,f))
6388 {
6389 return qe_invalid;
6390 }
6391
6392
1/2
✓ Branch 0 taken 106018 times.
✗ Branch 1 not taken.
106018 if(version < 0x193)
6393 {
6394 for(int32_t q=0; q<12; q++)
6395 {
6396 if(!p_getc(&padding,f))
6397 {
6398 return qe_invalid;
6399 }
6400 }
6401 }
6402
6403
2/2
✓ Branch 0 taken 101888 times.
✓ Branch 1 taken 4130 times.
106018 if(s_version>1)
6404 {
6405
2/2
✓ Branch 0 taken 49152 times.
✓ Branch 1 taken 52736 times.
101888 if ( s_version >= 31 )
6406 {
6407
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 49152 times.
49152 if(!p_igetl(&tempitem.family,f))
6408 {
6409 return qe_invalid;
6410 }
6411 49152 }
6412 else
6413 {
6414
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52736 times.
52736 if(!p_getc(&tempitem.family,f))
6415 {
6416 return qe_invalid;
6417 }
6418 }
6419
1/2
✓ Branch 0 taken 101888 times.
✗ Branch 1 not taken.
101888 if(s_version < 16)
6420 if(tempitem.family == 0xFF)
6421 tempitem.family = itype_misc;
6422
6423
1/2
✓ Branch 0 taken 101888 times.
✗ Branch 1 not taken.
101888 if(!p_getc(&tempitem.fam_type,f))
6424 {
6425 return qe_invalid;
6426 }
6427
6428
1/2
✓ Branch 0 taken 101888 times.
✗ Branch 1 not taken.
101888 if(s_version>5)
6429 {
6430
2/2
✓ Branch 0 taken 49152 times.
✓ Branch 1 taken 52736 times.
101888 if(s_version>=31)
6431 {
6432
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 49152 times.
49152 if(!p_igetl(&tempitem.power,f))
6433 {
6434 return qe_invalid;
6435 }
6436 49152 }
6437 else
6438 {
6439
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52736 times.
52736 if(!p_getc(&tempitem.power,f))
6440 {
6441 return qe_invalid;
6442 }
6443 }
6444
6445 //converted flags from 16b to 32b -Z
6446
2/2
✓ Branch 0 taken 52736 times.
✓ Branch 1 taken 49152 times.
101888 if ( s_version < 41 )
6447 {
6448
1/2
✓ Branch 0 taken 52736 times.
✗ Branch 1 not taken.
52736 if(!p_igetw(&tempitem.flags,f))
6449 {
6450 return qe_invalid;
6451 }
6452 52736 }
6453 else
6454 {
6455
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetl(&tempitem.flags,f))
6456 {
6457 return qe_invalid;
6458 }
6459 }
6460 101888 }
6461 else
6462 {
6463 //tempitem.power = tempitem.fam_type;
6464 char tempchar;
6465
6466 if(!p_getc(&tempchar,f))
6467 {
6468 return qe_invalid;
6469 }
6470
6471 if (tempchar) tempitem.flags |= item_gamedata;
6472 }
6473
6474
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101888 times.
101888 if(!p_igetw(&tempitem.script,f))
6475 {
6476 return qe_invalid;
6477 }
6478
6479
1/2
✓ Branch 0 taken 101888 times.
✗ Branch 1 not taken.
101888 if(s_version<=3)
6480 {
6481 if(tempitem.script > NUMSCRIPTITEM)
6482 {
6483 tempitem.script = 0;
6484 }
6485 }
6486
6487
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101888 times.
101888 if(!p_getc(&tempitem.count,f))
6488 {
6489 return qe_invalid;
6490 }
6491
6492
1/2
✓ Branch 0 taken 101888 times.
✗ Branch 1 not taken.
101888 if(!p_igetw(&tempitem.amount,f))
6493 {
6494 return qe_invalid;
6495 }
6496
6497
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101888 times.
101888 if(!p_igetw(&tempitem.collect_script,f))
6498 {
6499 return qe_invalid;
6500 }
6501
6502
1/2
✓ Branch 0 taken 101888 times.
✗ Branch 1 not taken.
101888 if(s_version<=3)
6503 {
6504 if(tempitem.collect_script > NUMSCRIPTITEM)
6505 {
6506 tempitem.collect_script = 0;
6507 }
6508 }
6509
6510
1/2
✓ Branch 0 taken 101888 times.
✗ Branch 1 not taken.
101888 if(!p_igetw(&tempitem.setmax,f))
6511 {
6512 return qe_invalid;
6513 }
6514
6515
1/2
✓ Branch 0 taken 101888 times.
✗ Branch 1 not taken.
101888 if(!p_igetw(&tempitem.max,f))
6516 {
6517 return qe_invalid;
6518 }
6519
6520
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101888 times.
101888 if(!p_getc(&tempitem.playsound,f))
6521 {
6522 return qe_invalid;
6523 }
6524
6525
2/2
✓ Branch 0 taken 815104 times.
✓ Branch 1 taken 101888 times.
916992 for(int32_t j=0; j<8; j++)
6526 {
6527
1/2
✓ Branch 0 taken 815104 times.
✗ Branch 1 not taken.
815104 if(!p_igetl(&tempitem.initiald[j],f))
6528 {
6529 return qe_invalid;
6530 }
6531 815104 }
6532
6533
2/2
✓ Branch 0 taken 203776 times.
✓ Branch 1 taken 101888 times.
305664 for(int32_t j=0; j<2; j++)
6534 {
6535 byte temp;
6536
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(!p_getc(&temp,f))
6537 {
6538 return qe_invalid;
6539 }
6540 203776 }
6541
6542
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101888 times.
101888 if(s_version>4)
6543 {
6544
1/2
✓ Branch 0 taken 101888 times.
✗ Branch 1 not taken.
101888 if(s_version>5)
6545 {
6546
1/2
✓ Branch 0 taken 101888 times.
✗ Branch 1 not taken.
101888 if(!p_getc(&tempitem.wpn,f))
6547 {
6548 return qe_invalid;
6549 }
6550
6551
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101888 times.
101888 if(!p_getc(&tempitem.wpn2,f))
6552 {
6553 return qe_invalid;
6554 }
6555
6556
1/2
✓ Branch 0 taken 101888 times.
✗ Branch 1 not taken.
101888 if(!p_getc(&tempitem.wpn3,f))
6557 {
6558 return qe_invalid;
6559 }
6560
6561
1/2
✓ Branch 0 taken 101888 times.
✗ Branch 1 not taken.
101888 if(!p_getc(&tempitem.wpn4,f))
6562 {
6563 return qe_invalid;
6564 }
6565
6566
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101888 times.
101888 if(s_version>=15)
6567 {
6568
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101888 times.
101888 if(!p_getc(&tempitem.wpn5,f))
6569 {
6570 return qe_invalid;
6571 }
6572
6573
1/2
✓ Branch 0 taken 101888 times.
✗ Branch 1 not taken.
101888 if(!p_getc(&tempitem.wpn6,f))
6574 {
6575 return qe_invalid;
6576 }
6577
6578
1/2
✓ Branch 0 taken 101888 times.
✗ Branch 1 not taken.
101888 if(!p_getc(&tempitem.wpn7,f))
6579 {
6580 return qe_invalid;
6581 }
6582
6583
1/2
✓ Branch 0 taken 101888 times.
✗ Branch 1 not taken.
101888 if(!p_getc(&tempitem.wpn8,f))
6584 {
6585 return qe_invalid;
6586 }
6587
6588
1/2
✓ Branch 0 taken 101888 times.
✗ Branch 1 not taken.
101888 if(!p_getc(&tempitem.wpn9,f))
6589 {
6590 return qe_invalid;
6591 }
6592
6593
1/2
✓ Branch 0 taken 101888 times.
✗ Branch 1 not taken.
101888 if(!p_getc(&tempitem.wpn10,f))
6594 {
6595 return qe_invalid;
6596 }
6597 101888 }
6598
6599
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101888 times.
101888 if(!p_getc(&tempitem.pickup_hearts,f))
6600 {
6601 return qe_invalid;
6602 }
6603
6604
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101888 times.
101888 if(s_version<15)
6605 {
6606 if(!p_igetw(&dummy_word,f))
6607 {
6608 return qe_invalid;
6609 }
6610
6611 tempitem.misc1=dummy_word;
6612
6613 if(!p_igetw(&dummy_word,f))
6614 {
6615 return qe_invalid;
6616 }
6617
6618 tempitem.misc2=dummy_word;
6619 }
6620 else
6621 {
6622
1/2
✓ Branch 0 taken 101888 times.
✗ Branch 1 not taken.
101888 if(!p_igetl(&tempitem.misc1,f))
6623 {
6624 return qe_invalid;
6625 }
6626
6627
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101888 times.
101888 if(!p_igetl(&tempitem.misc2,f))
6628 {
6629 return qe_invalid;
6630 }
6631
6632 // Version 24: sh_ice -> sh_script; previously, all shields could block script weapons
6633
1/2
✓ Branch 0 taken 101888 times.
✗ Branch 1 not taken.
101888 if(s_version<24)
6634 {
6635 if(tempitem.family==itype_shield)
6636 {
6637 tempitem.misc1|=sh_script;
6638 }
6639 }
6640 }
6641
6642
2/2
✓ Branch 0 taken 52736 times.
✓ Branch 1 taken 49152 times.
101888 if(s_version < 53)
6643 {
6644 byte tempbyte;
6645
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52736 times.
52736 if(!p_getc(&tempbyte,f))
6646 {
6647 return qe_invalid;
6648 }
6649 52736 tempitem.cost_amount[0] = tempbyte;
6650 52736 }
6651 else
6652 {
6653
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 49152 times.
147456 for(auto q = 0; q < 2; ++q)
6654 {
6655
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98304 times.
98304 if(!p_igetw(&tempitem.cost_amount[q],f))
6656 {
6657 return qe_invalid;
6658 }
6659 98304 }
6660 }
6661 101888 }
6662 else
6663 {
6664 char tempchar;
6665
6666 if(!p_getc(&tempchar,f))
6667 {
6668 return qe_invalid;
6669 }
6670
6671 if (tempchar) tempitem.flags |= item_edible;
6672 }
6673
6674 // June 2007: more misc. attributes
6675
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101888 times.
101888 if(s_version>=12)
6676 {
6677
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101888 times.
101888 if(s_version<15)
6678 {
6679 if(!p_igetw(&dummy_word,f))
6680 {
6681 return qe_invalid;
6682 }
6683
6684 tempitem.misc3=dummy_word;
6685
6686 if(!p_igetw(&dummy_word,f))
6687 {
6688 return qe_invalid;
6689 }
6690
6691 tempitem.misc4=dummy_word;
6692 }
6693 else
6694 {
6695
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101888 times.
101888 if(!p_igetl(&tempitem.misc3,f))
6696 {
6697 return qe_invalid;
6698 }
6699
6700
1/2
✓ Branch 0 taken 101888 times.
✗ Branch 1 not taken.
101888 if(!p_igetl(&tempitem.misc4,f))
6701 {
6702 return qe_invalid;
6703 }
6704
6705
1/2
✓ Branch 0 taken 101888 times.
✗ Branch 1 not taken.
101888 if(!p_igetl(&tempitem.misc5,f))
6706 {
6707 return qe_invalid;
6708 }
6709
6710
1/2
✓ Branch 0 taken 101888 times.
✗ Branch 1 not taken.
101888 if(!p_igetl(&tempitem.misc6,f))
6711 {
6712 return qe_invalid;
6713 }
6714
6715
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101888 times.
101888 if(!p_igetl(&tempitem.misc7,f))
6716 {
6717 return qe_invalid;
6718 }
6719
6720
1/2
✓ Branch 0 taken 101888 times.
✗ Branch 1 not taken.
101888 if(!p_igetl(&tempitem.misc8,f))
6721 {
6722 return qe_invalid;
6723 }
6724
6725
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101888 times.
101888 if(!p_igetl(&tempitem.misc9,f))
6726 {
6727 return qe_invalid;
6728 }
6729
6730
1/2
✓ Branch 0 taken 101888 times.
✗ Branch 1 not taken.
101888 if(!p_igetl(&tempitem.misc10,f))
6731 {
6732 return qe_invalid;
6733 }
6734 }
6735
6736
1/2
✓ Branch 0 taken 101888 times.
✗ Branch 1 not taken.
101888 if(!p_getc(&tempitem.usesound,f))
6737 {
6738 return qe_invalid;
6739 }
6740
6741
2/2
✓ Branch 0 taken 49152 times.
✓ Branch 1 taken 52736 times.
101888 if(s_version >= 49)
6742 {
6743
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 49152 times.
49152 if(!p_getc(&tempitem.usesound2,f))
6744 {
6745 return qe_invalid;
6746 }
6747 49152 }
6748 52736 else tempitem.usesound2 = 0;
6749
6750
3/4
✓ Branch 0 taken 52736 times.
✓ Branch 1 taken 49152 times.
✓ Branch 2 taken 52736 times.
✗ Branch 3 not taken.
101888 if(s_version < 50 && tempitem.family == itype_mirror)
6751 {
6752 //Split continue/dmap warp effect/sfx, port for old
6753 tempitem.misc2 = tempitem.misc1;
6754 tempitem.usesound2 = tempitem.usesound;
6755 }
6756 101888 }
6757 101888 }
6758
6759
2/2
✓ Branch 0 taken 52736 times.
✓ Branch 1 taken 49152 times.
101888 if ( s_version >= 26 ) //! New itemdata vars for weapon editor. -Z
6760 { // temp.useweapon, temp.usedefence, temp.weaprange, temp.weap_pattern[ITEM_MOVEMENT_PATTERNS]
6761
2/2
✓ Branch 0 taken 31232 times.
✓ Branch 1 taken 17920 times.
49152 if(s_version < 63)
6762 {
6763
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17920 times.
17920 if(!p_getc(&tempitem.weap_data.imitate_weapon,f))
6764 {
6765 return qe_invalid;
6766 }
6767
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_getc(&tempitem.weap_data.default_defense,f))
6768 {
6769 return qe_invalid;
6770 }
6771 17920 }
6772
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetl(&tempitem.weaprange,f))
6773 {
6774 return qe_invalid;
6775 }
6776
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 49152 times.
49152 if(!p_igetl(&tempitem.weapduration,f))
6777 {
6778 return qe_invalid;
6779 }
6780
2/2
✓ Branch 0 taken 491520 times.
✓ Branch 1 taken 49152 times.
540672 for ( int32_t q = 0; q < ITEM_MOVEMENT_PATTERNS; q++ )
6781 {
6782
1/2
✓ Branch 0 taken 491520 times.
✗ Branch 1 not taken.
491520 if(!p_igetl(&tempitem.weap_pattern[q],f))
6783 {
6784 return qe_invalid;
6785 }
6786 491520 }
6787 49152 }
6788
6789
2/2
✓ Branch 0 taken 52736 times.
✓ Branch 1 taken 49152 times.
101888 if ( s_version >= 27 ) //! New itemdata vars for weapon editor. -Z
6790 { // temp.useweapon, temp.usedefence, temp.weaprange, temp.weap_pattern[ITEM_MOVEMENT_PATTERNS]
6791
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 49152 times.
49152 if(!p_igetl(&tempitem.duplicates,f))
6792 {
6793 return qe_invalid;
6794 }
6795
2/2
✓ Branch 0 taken 31232 times.
✓ Branch 1 taken 17920 times.
49152 if(s_version < 63)
6796
2/2
✓ Branch 0 taken 143360 times.
✓ Branch 1 taken 17920 times.
161280 for ( int32_t q = 0; q < INITIAL_D; q++ )
6797
1/2
✓ Branch 0 taken 143360 times.
✗ Branch 1 not taken.
143360 if(!p_igetl(&tempitem.weap_data.initd[q],f))
6798 17920 return qe_invalid;
6799
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 49152 times.
147456 for ( int32_t q = 0; q < 2; q++ )
6800 {
6801 byte temp;
6802
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98304 times.
98304 if(!p_getc(&temp,f))
6803 {
6804 return qe_invalid;
6805 }
6806 98304 }
6807
6808
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_getc(&tempitem.drawlayer,f))
6809 {
6810 return qe_invalid;
6811 }
6812
6813
6814
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetl(&tempitem.hxofs,f))
6815 {
6816 return qe_invalid;
6817 }
6818
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 49152 times.
49152 if(!p_igetl(&tempitem.hyofs,f))
6819 {
6820 return qe_invalid;
6821 }
6822
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetl(&tempitem.hxsz,f))
6823 {
6824 return qe_invalid;
6825 }
6826
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 49152 times.
49152 if(!p_igetl(&tempitem.hysz,f))
6827 {
6828 return qe_invalid;
6829 }
6830
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetl(&tempitem.hzsz,f))
6831 {
6832 return qe_invalid;
6833 }
6834
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 49152 times.
49152 if(!p_igetl(&tempitem.xofs,f))
6835 {
6836 return qe_invalid;
6837 }
6838
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 49152 times.
49152 if(!p_igetl(&tempitem.yofs,f))
6839 {
6840 return qe_invalid;
6841 }
6842
2/2
✓ Branch 0 taken 31232 times.
✓ Branch 1 taken 17920 times.
49152 if(s_version < 63)
6843 {
6844
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17920 times.
17920 if(!p_igetl(&tempitem.weap_data.hxofs,f))
6845 return qe_invalid;
6846
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_igetl(&tempitem.weap_data.hyofs,f))
6847 return qe_invalid;
6848
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_igetl(&tempitem.weap_data.hxsz,f))
6849 return qe_invalid;
6850
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_igetl(&tempitem.weap_data.hysz,f))
6851 return qe_invalid;
6852
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_igetl(&tempitem.weap_data.hzsz,f))
6853 return qe_invalid;
6854
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_igetl(&tempitem.weap_data.xofs,f))
6855 return qe_invalid;
6856
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17920 times.
17920 if(!p_igetl(&tempitem.weap_data.yofs,f))
6857 return qe_invalid;
6858 17920 }
6859
2/2
✓ Branch 0 taken 31232 times.
✓ Branch 1 taken 17920 times.
49152 if(s_version < 63)
6860
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_igetw(&tempitem.weap_data.script,f))
6861 return qe_invalid;
6862
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetl(&tempitem.wpnsprite,f))
6863 {
6864 return qe_invalid;
6865 }
6866 49152 auto num_cost_tmr = (s_version > 52 ? 2 : 1);
6867
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 49152 times.
147456 for(auto q = 0; q < num_cost_tmr; ++q)
6868 {
6869
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98304 times.
98304 if(!p_igetl(&tempitem.magiccosttimer[q],f))
6870 {
6871 return qe_invalid;
6872 }
6873 98304 }
6874
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 49152 times.
49152 for(auto q = num_cost_tmr; q < 2; ++q)
6875 tempitem.magiccosttimer[q] = 0;
6876 49152 }
6877
2/2
✓ Branch 0 taken 52736 times.
✓ Branch 1 taken 49152 times.
101888 if ( s_version >= 28 ) //! New itemdata vars for weapon editor. -Z
6878 {
6879 //Item Size FLags, TileWidth, TileHeight
6880
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetl(&tempitem.overrideFLAGS,f))
6881 {
6882 return qe_invalid;
6883 }
6884
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 49152 times.
49152 if(!p_igetl(&tempitem.tilew,f))
6885 {
6886 return qe_invalid;
6887 }
6888
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 49152 times.
49152 if(!p_igetl(&tempitem.tileh,f))
6889 {
6890 return qe_invalid;
6891 }
6892 49152 }
6893
4/4
✓ Branch 0 taken 49152 times.
✓ Branch 1 taken 52736 times.
✓ Branch 2 taken 31232 times.
✓ Branch 3 taken 17920 times.
101888 if ( s_version >= 29 && s_version < 63) //! More new vars.
6894 {
6895
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_igetl(&tempitem.weap_data.override_flags,f))
6896 return qe_invalid;
6897
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_igetl(&tempitem.weap_data.tilew,f))
6898 return qe_invalid;
6899
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_igetl(&tempitem.weap_data.tileh,f))
6900 return qe_invalid;
6901 17920 }
6902
2/2
✓ Branch 0 taken 52736 times.
✓ Branch 1 taken 49152 times.
101888 if ( s_version >= 30 ) //! More new vars.
6903 {
6904 //Pickup Type
6905
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetl(&tempitem.pickup,f))
6906 {
6907 return qe_invalid;
6908 }
6909 49152 }
6910
2/2
✓ Branch 0 taken 52736 times.
✓ Branch 1 taken 49152 times.
101888 if ( s_version >= 32 ) //! More new vars.
6911 {
6912 //Pickup Type
6913
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetw(&tempitem.pstring,f))
6914 {
6915 return qe_invalid;
6916 }
6917 49152 }
6918
2/2
✓ Branch 0 taken 52736 times.
✓ Branch 1 taken 49152 times.
101888 if ( s_version >= 33 ) //! More new vars.
6919 {
6920 //Pickup Type
6921
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetw(&tempitem.pickup_string_flags,f))
6922 {
6923 return qe_invalid;
6924 }
6925 49152 }
6926
2/2
✓ Branch 0 taken 52736 times.
✓ Branch 1 taken 49152 times.
101888 if ( s_version >= 34 ) //! cost counter
6927 {
6928
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 49152 times.
49152 if(s_version < 53)
6929 {
6930 if(!p_getc(&tempitem.cost_counter[0],f))
6931 {
6932 return qe_invalid;
6933 }
6934 }
6935 else
6936 {
6937
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 49152 times.
147456 for(auto q = 0; q < 2; ++q)
6938 {
6939
1/2
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
98304 if(!p_getc(&tempitem.cost_counter[q],f))
6940 {
6941 return qe_invalid;
6942 }
6943 98304 }
6944 }
6945 49152 }
6946
2/2
✓ Branch 0 taken 52736 times.
✓ Branch 1 taken 49152 times.
101888 if ( s_version >= 44 ) //! sprite scripts
6947 {
6948
2/2
✓ Branch 0 taken 393216 times.
✓ Branch 1 taken 49152 times.
442368 for ( int32_t q = 0; q < 8; q++ )
6949 {
6950
2/2
✓ Branch 0 taken 25559040 times.
✓ Branch 1 taken 393216 times.
25952256 for ( int32_t w = 0; w < 65; w++ )
6951 {
6952
1/2
✓ Branch 0 taken 25559040 times.
✗ Branch 1 not taken.
25559040 if(!p_getc(&(tempitem.initD_label[q][w]),f))
6953 {
6954 return qe_invalid;
6955 }
6956 25559040 }
6957
2/2
✓ Branch 0 taken 249856 times.
✓ Branch 1 taken 143360 times.
393216 if(s_version < 63)
6958
2/2
✓ Branch 0 taken 9318400 times.
✓ Branch 1 taken 143360 times.
9461760 for ( int32_t w = 0; w < 65; w++ )
6959
1/2
✓ Branch 0 taken 9318400 times.
✗ Branch 1 not taken.
9318400 if(!p_getc(&padding,f))
6960 143360 return qe_invalid;
6961
2/2
✓ Branch 0 taken 25559040 times.
✓ Branch 1 taken 393216 times.
25952256 for ( int32_t w = 0; w < 65; w++ )
6962 {
6963
1/2
✓ Branch 0 taken 25559040 times.
✗ Branch 1 not taken.
25559040 if(!p_getc(&(tempitem.sprite_initD_label[q][w]),f))
6964 {
6965 return qe_invalid;
6966 }
6967 25559040 }
6968
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 393216 times.
393216 if(!p_igetl(&(tempitem.sprite_initiald[q]),f))
6969 {
6970 return qe_invalid;
6971 }
6972
6973 393216 }
6974
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 49152 times.
147456 for ( int32_t q = 0; q < 2; q++ )
6975 {
6976 byte temp;
6977
1/2
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
98304 if(!p_getc(&temp,f))
6978 {
6979 return qe_invalid;
6980 }
6981 98304 }
6982 //Pickup Type
6983
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetw(&tempitem.sprite_script,f))
6984 {
6985 return qe_invalid;
6986 }
6987 49152 }
6988
2/2
✓ Branch 0 taken 52736 times.
✓ Branch 1 taken 49152 times.
101888 if ( s_version >= 48 ) //! pickup flags
6989 {
6990
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 49152 times.
49152 if(!p_getc(&(tempitem.pickupflag),f))
6991 {
6992 return qe_invalid;
6993 }
6994 49152 }
6995
2/2
✓ Branch 0 taken 56064 times.
✓ Branch 1 taken 45824 times.
101888 if ( s_version >= 57 )
6996 {
6997 45824 std::string str;
6998
2/4
✓ Branch 0 taken 45824 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 45824 times.
✗ Branch 3 not taken.
45824 if(!p_getcstr(&str,f))
6999 return qe_invalid;
7000 45824 strncpy(tempitem.display_name,str.c_str(),255);
7001
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 45824 times.
45824 }
7002 101888 }
7003 else
7004 {
7005 4130 tempitem.count=-1;
7006 4130 tempitem.family=itype_misc;
7007 4130 tempitem.flags=item_none;
7008 4130 tempitem.wpn=tempitem.wpn2=tempitem.wpn3=tempitem.wpn3=tempitem.pickup_hearts=tempitem.misc1=tempitem.misc2=tempitem.usesound=0;
7009 4130 tempitem.playsound=WAV_SCALE;
7010 4130 reset_itembuf(&tempitem,i);
7011 }
7012
7013
4/4
✓ Branch 0 taken 44800 times.
✓ Branch 1 taken 61218 times.
✓ Branch 2 taken 31232 times.
✓ Branch 3 taken 13568 times.
106018 if(s_version >= 58 && s_version < 63)
7014 {
7015
2/2
✓ Branch 0 taken 67840 times.
✓ Branch 1 taken 13568 times.
81408 for(int q = 0; q < WPNSPR_MAX; ++q)
7016 {
7017
1/2
✓ Branch 0 taken 67840 times.
✗ Branch 1 not taken.
67840 if(!p_getc(&tempitem.weap_data.burnsprs[q],f))
7018 return qe_invalid;
7019
2/2
✓ Branch 0 taken 1280 times.
✓ Branch 1 taken 66560 times.
67840 if(s_version >= 59)
7020
1/2
✓ Branch 0 taken 66560 times.
✗ Branch 1 not taken.
66560 if(!p_getc(&tempitem.weap_data.light_rads[q],f))
7021 return qe_invalid;
7022 67840 }
7023 13568 }
7024
7025
2/2
✓ Branch 0 taken 72994 times.
✓ Branch 1 taken 33024 times.
106018 if ( s_version >= 60 )
7026 {
7027
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33024 times.
33024 if(!p_getc(&tempitem.pickup_litems,f))
7028 return qe_invalid;
7029
1/2
✓ Branch 0 taken 33024 times.
✗ Branch 1 not taken.
33024 if(!p_igetw(&tempitem.pickup_litem_level,f))
7030 return qe_invalid;
7031 33024 }
7032
7033
2/2
✓ Branch 0 taken 32768 times.
✓ Branch 1 taken 73250 times.
106018 if ( s_version >= 62 )
7034 {
7035
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32768 times.
32768 if (!p_igetl(&tempitem.moveflags, f))
7036 return qe_invalid;
7037
2/2
✓ Branch 0 taken 31232 times.
✓ Branch 1 taken 1536 times.
32768 if(s_version < 63)
7038
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1536 times.
1536 if (!p_igetl(&tempitem.weap_data.moveflags, f))
7039 return qe_invalid;
7040 32768 }
7041 else
7042 {
7043 73250 tempitem.moveflags = (move_obeys_grav | move_can_pitfall);
7044
3/3
✓ Branch 0 taken 2094 times.
✓ Branch 1 taken 70830 times.
✓ Branch 2 taken 326 times.
73250 switch(tempitem.family)
7045 {
7046 case itype_divinefire:
7047
2/2
✓ Branch 0 taken 187 times.
✓ Branch 1 taken 139 times.
326 if(!(tempitem.flags & item_flag3))
7048 139 break;
7049 [[fallthrough]];
7050 case itype_bomb: case itype_sbomb:
7051 case itype_bait: case itype_liftglove:
7052 case itype_candle: case itype_book:
7053 2281 tempitem.weap_data.moveflags = (move_obeys_grav | move_can_pitfall);
7054 2281 break;
7055 default:
7056 70830 tempitem.weap_data.moveflags = move_none;
7057 70830 break;
7058 }
7059 }
7060
7061
2/2
✓ Branch 0 taken 31232 times.
✓ Branch 1 taken 74786 times.
106018 if(s_version >= 63)
7062 {
7063
1/2
✓ Branch 0 taken 31232 times.
✗ Branch 1 not taken.
31232 if(auto ret = read_weap_data(tempitem.weap_data, f))
7064 return ret;
7065 31232 }
7066 else
7067 {
7068
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 74769 times.
74786 SETFLAG(tempitem.weap_data.wflags, WFLAG_UPDATE_IGNITE_SPRITE, tempitem.flags & item_burning_sprites);
7069
3/3
✓ Branch 0 taken 680 times.
✓ Branch 1 taken 74022 times.
✓ Branch 2 taken 84 times.
74786 switch(tempitem.family)
7070 {
7071 case itype_liftglove:
7072 84 tempitem.weap_data.wflags = WFLAG_BREAK_WHEN_LANDING;
7073 84 break;
7074 case itype_bomb: case itype_sbomb:
7075 // Moving these over and removing them from itemdata
7076
2/2
✓ Branch 0 taken 657 times.
✓ Branch 1 taken 23 times.
680 if(tempitem.flags & item_flag3)
7077 23 tempitem.weap_data.wflags |= WFLAG_STOP_WHEN_LANDING;
7078
2/2
✓ Branch 0 taken 657 times.
✓ Branch 1 taken 23 times.
680 if(tempitem.flags & item_flag5)
7079 23 tempitem.weap_data.wflags |= WFLAG_STOP_WHEN_HIT_SOLID;
7080 680 tempitem.flags &= ~(item_flag3|item_flag5);
7081
2/2
✓ Branch 0 taken 663 times.
✓ Branch 1 taken 17 times.
680 if(tempitem.misc4)
7082 {
7083 17 tempitem.weap_data.lift_level = tempitem.misc4;
7084 17 tempitem.weap_data.lift_time = tempitem.misc5;
7085 17 tempitem.weap_data.lift_height = tempitem.misc6;
7086 17 tempitem.misc4 = 0;
7087 17 tempitem.misc5 = 0;
7088 17 tempitem.misc6 = 0;
7089 17 }
7090 680 break;
7091 }
7092 }
7093
7094
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106018 times.
106018 if (!should_skip)
7095 {
7096
1/2
✓ Branch 0 taken 106018 times.
✗ Branch 1 not taken.
106018 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
7097 {
7098 tempitem.script = 0;
7099 tempitem.weap_data.script = 0;
7100 for(int q = 0; q < 8; ++q)
7101 {
7102 tempitem.initiald[q] = 0;
7103 tempitem.weap_data.initd[q] = 0;
7104 }
7105 }
7106 106018 itemsbuf[i] = tempitem;
7107 106018 }
7108 106018 }
7109
7110
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 480 times.
481 if (should_skip)
7111 1 return 0;
7112
7113 //////////////////////////////////////////////////////
7114 // Now do any updates because of new item additions
7115 // (These can't be done above because items_to_read
7116 // might be too low.)
7117 //////////////////////////////////////////////////////
7118
2/2
✓ Branch 0 taken 122880 times.
✓ Branch 1 taken 480 times.
123360 for(int32_t i=0; i<MAXITEMS; i++)
7119 {
7120 122880 tempitem = itemsbuf[i];
7121
7122 //Account for older quests that didn't have an actual item for the used letter
7123
4/4
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 101888 times.
✓ Branch 2 taken 20910 times.
✓ Branch 3 taken 82 times.
122880 if(s_version < 2 && i==iLetterUsed)
7124 {
7125 82 reset_itembuf(&tempitem, iLetterUsed);
7126 82 strcpy(item_string[i],old_item_string[i]);
7127 82 tempitem.tile = itemsbuf[iLetter].tile;
7128 82 tempitem.csets = itemsbuf[iLetter].csets;
7129 82 tempitem.misc_flags = itemsbuf[iLetter].misc_flags;
7130 82 tempitem.frames = itemsbuf[iLetter].frames;
7131 82 tempitem.speed = itemsbuf[iLetter].speed;
7132 82 tempitem.ltm = itemsbuf[iLetter].ltm;
7133 82 }
7134
7135
2/2
✓ Branch 0 taken 101888 times.
✓ Branch 1 taken 20992 times.
122880 if(s_version < 3)
7136 {
7137
3/3
✓ Branch 0 taken 1804 times.
✓ Branch 1 taken 19106 times.
✓ Branch 2 taken 82 times.
20992 switch(i)
7138 {
7139 case iRocsFeather:
7140 case iHoverBoots:
7141 case iSpinScroll:
7142 case iL2SpinScroll:
7143 case iCrossScroll:
7144 case iQuakeScroll:
7145 case iL2QuakeScroll:
7146 case iWhispRing:
7147 case iL2WhispRing:
7148 case iChargeRing:
7149 case iL2ChargeRing:
7150 case iPerilScroll:
7151 case iWalletL3:
7152 case iQuiverL4:
7153 case iBombBagL4:
7154 case iBracelet:
7155 case iL2Bracelet:
7156 case iOldGlove:
7157 case iL2Ladder:
7158 case iWealthMedal:
7159 case iL2WealthMedal:
7160 case iL3WealthMedal:
7161 1804 reset_itembuf(&tempitem, i);
7162 1804 strcpy(item_string[i],old_item_string[i]);
7163 1804 break;
7164
7165 case iSShield:
7166 82 reset_itembuf(&tempitem, i);
7167 82 strcpy(item_string[i],old_item_string[i]);
7168 82 strcpy(item_string[iShield],old_item_string[iShield]);
7169 82 strcpy(item_string[iMShield],old_item_string[iMShield]);
7170 82 break;
7171 }
7172 20992 }
7173
7174
2/2
✓ Branch 0 taken 101888 times.
✓ Branch 1 taken 20992 times.
122880 if(s_version < 5)
7175 {
7176
2/2
✓ Branch 0 taken 574 times.
✓ Branch 1 taken 20418 times.
20992 switch(i)
7177 {
7178 case iHeartRing:
7179 case iL2HeartRing:
7180 case iL3HeartRing:
7181 case iMagicRing:
7182 case iL2MagicRing:
7183 case iL3MagicRing:
7184 case iL4MagicRing:
7185 574 reset_itembuf(&tempitem, i);
7186 574 strcpy(item_string[i],old_item_string[i]);
7187 574 break;
7188 }
7189 20992 }
7190
7191
2/2
✓ Branch 0 taken 101888 times.
✓ Branch 1 taken 20992 times.
122880 if(s_version < 6) // April 2007: Advanced item editing capabilities.
7192 {
7193
4/4
✓ Branch 0 taken 20910 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 20828 times.
20992 if(i!=iBPotion && i!=iRPotion)
7194
2/2
✓ Branch 0 taken 1524 times.
✓ Branch 1 taken 19304 times.
20828 if (get_bit(deprecated_rules,32)) tempitem.flags |= item_keep_old;
7195
7196
43/43
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 82 times.
✓ Branch 4 taken 82 times.
✓ Branch 5 taken 82 times.
✓ Branch 6 taken 82 times.
✓ Branch 7 taken 82 times.
✓ Branch 8 taken 82 times.
✓ Branch 9 taken 82 times.
✓ Branch 10 taken 328 times.
✓ Branch 11 taken 17302 times.
✓ Branch 12 taken 82 times.
✓ Branch 13 taken 82 times.
✓ Branch 14 taken 82 times.
✓ Branch 15 taken 82 times.
✓ Branch 16 taken 82 times.
✓ Branch 17 taken 82 times.
✓ Branch 18 taken 82 times.
✓ Branch 19 taken 82 times.
✓ Branch 20 taken 82 times.
✓ Branch 21 taken 82 times.
✓ Branch 22 taken 82 times.
✓ Branch 23 taken 82 times.
✓ Branch 24 taken 82 times.
✓ Branch 25 taken 82 times.
✓ Branch 26 taken 82 times.
✓ Branch 27 taken 82 times.
✓ Branch 28 taken 82 times.
✓ Branch 29 taken 82 times.
✓ Branch 30 taken 82 times.
✓ Branch 31 taken 82 times.
✓ Branch 32 taken 82 times.
✓ Branch 33 taken 82 times.
✓ Branch 34 taken 82 times.
✓ Branch 35 taken 82 times.
✓ Branch 36 taken 82 times.
✓ Branch 37 taken 82 times.
✓ Branch 38 taken 82 times.
✓ Branch 39 taken 82 times.
✓ Branch 40 taken 82 times.
✓ Branch 41 taken 82 times.
✓ Branch 42 taken 82 times.
20992 switch(i)
7197 {
7198 case iTriforce:
7199 82 tempitem.fam_type=1;
7200 82 break;
7201
7202 case iBigTri:
7203 82 tempitem.fam_type=0;
7204 82 break;
7205
7206 case iBombs:
7207 82 tempitem.fam_type=i_bomb;
7208 82 tempitem.power=4;
7209 82 tempitem.wpn=wBOMB;
7210 82 tempitem.wpn2=wBOOM;
7211 82 tempitem.misc1 = 50;
7212
7213
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if(get_bit(deprecated_rules,qr_SLOWBOMBFUSES_DEP)) tempitem.misc1 = 200;
7214
7215 82 break;
7216
7217 case iSBomb:
7218 82 tempitem.fam_type=i_sbomb;
7219 82 tempitem.power=16;
7220 82 tempitem.wpn=wSBOMB;
7221 82 tempitem.wpn2=wSBOOM;
7222 82 tempitem.misc1 = 50;
7223
7224
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if(get_bit(deprecated_rules,qr_SLOWBOMBFUSES_DEP)) tempitem.misc1 = 400;
7225
7226 82 break;
7227
7228 case iBook:
7229
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if(get_bit(deprecated_rules, qr_FIREMAGICSPRITE_DEP))
7230 tempitem.wpn = wFIREMAGIC;
7231
7232 82 break;
7233
7234 case iSArrow:
7235 82 tempitem.wpn2 = get_bit(deprecated_rules,27) ? wSSPARKLE : 0; //qr_SASPARKLES
7236 82 tempitem.power=4;
7237 82 tempitem.flags|=item_gamedata;
7238 82 tempitem.wpn=wSARROW;
7239 82 break;
7240
7241 case iGArrow:
7242 82 tempitem.wpn2 = get_bit(deprecated_rules,28) ? wGSPARKLE : 0; //qr_GASPARKLES
7243 82 tempitem.power=8;
7244 82 tempitem.flags|=(item_gamedata|item_flag1);
7245 82 tempitem.wpn=wGARROW;
7246 82 break;
7247
7248 case iBrang:
7249 82 tempitem.power=0;
7250 82 tempitem.wpn=wBRANG;
7251 82 tempitem.misc1=36;
7252 82 break;
7253
7254 case iMBrang:
7255 82 tempitem.wpn2 = get_bit(deprecated_rules,29) ? wMSPARKLE : 0; //qr_MBSPARKLES
7256 82 tempitem.power=0;
7257 82 tempitem.wpn=wMBRANG;
7258 82 break;
7259
7260 case iFBrang:
7261 82 tempitem.wpn3 = get_bit(deprecated_rules,30) ? wFSPARKLE : 0; //qr_FBSPARKLES
7262 82 tempitem.power=2;
7263 82 tempitem.wpn=wFBRANG;
7264 82 break;
7265
7266 case iBoots:
7267 82 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICBOOTS_DEP) ? 1 : 0;
7268 82 tempitem.power=7;
7269 82 break;
7270
7271 case iWand:
7272 82 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICWAND_DEP) ? 8 : 0;
7273 82 tempitem.power=2;
7274 82 tempitem.wpn=wWAND;
7275 82 tempitem.wpn3=wMAGIC;
7276 82 break;
7277
7278 case iBCandle:
7279 82 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICCANDLE_DEP) ? 4 : 0;
7280 82 tempitem.power=1;
7281 82 tempitem.flags|=(item_gamedata|item_flag1);
7282 82 tempitem.wpn3=wFIRE;
7283 82 break;
7284
7285 case iRCandle:
7286 82 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICCANDLE_DEP) ? 4 : 0;
7287 82 tempitem.power=1;
7288 82 tempitem.wpn3=wFIRE;
7289 82 break;
7290
7291 case iSword:
7292 82 tempitem.power=1;
7293 82 tempitem.flags|= item_flag4 |item_flag2;
7294 82 tempitem.wpn=tempitem.wpn3=wSWORD;
7295 82 tempitem.wpn2=wSWORDSLASH;
7296 82 break;
7297
7298 case iWSword:
7299 82 tempitem.power=2;
7300 82 tempitem.flags|= item_flag4 |item_flag2;
7301 82 tempitem.wpn=tempitem.wpn3=wWSWORD;
7302 82 tempitem.wpn2=wWSWORDSLASH;
7303 82 break;
7304
7305 case iMSword:
7306 82 tempitem.power=4;
7307 82 tempitem.flags|= item_flag4 |item_flag2;
7308 82 tempitem.wpn=tempitem.wpn3=wMSWORD;
7309 82 tempitem.wpn2=wMSWORDSLASH;
7310 82 break;
7311
7312 case iXSword:
7313 82 tempitem.power=8;
7314 82 tempitem.flags|= item_flag4 |item_flag2;
7315 82 tempitem.wpn=tempitem.wpn3=wXSWORD;
7316 82 tempitem.wpn2=wXSWORDSLASH;
7317 82 break;
7318
7319 case iDivineProtection:
7320 82 tempitem.flags |= get_bit(deprecated_rules,qr_FLICKERINGDIVINEPROTECTIONROCKET_DEP) ? item_flag1 : item_none;
7321 82 tempitem.flags |= get_bit(deprecated_rules,qr_TRANSLUCENTDIVINEPROTECTIONROCKET_DEP) ? item_flag2 : item_none;
7322 82 tempitem.wpn=wDIVINEPROTECTION1A;
7323 82 tempitem.wpn2=wDIVINEPROTECTION1B;
7324 82 tempitem.wpn3=wDIVINEPROTECTIONS1A;
7325 82 tempitem.wpn4=wDIVINEPROTECTIONS1B;
7326 82 tempitem.wpn6=wDIVINEPROTECTION2A;
7327 82 tempitem.wpn7=wDIVINEPROTECTION2B;
7328 82 tempitem.wpn8=wDIVINEPROTECTIONS2A;
7329 82 tempitem.wpn9=wDIVINEPROTECTIONS2B;
7330 82 tempitem.wpn5 = iwDivineProtectionShieldFront;
7331 82 tempitem.wpn10 = iwDivineProtectionShieldBack;
7332 82 tempitem.misc1=512;
7333 82 tempitem.cost_amount[0]=64;
7334 82 break;
7335
7336 case iLens:
7337 82 tempitem.misc1=60;
7338 82 tempitem.flags |= get_qr(qr_ENABLEMAGIC) ? item_none : item_rupee_magic;
7339 82 tempitem.cost_amount[0] = get_qr(qr_ENABLEMAGIC) ? 2 : 1;
7340 82 break;
7341
7342 case iArrow:
7343 82 tempitem.power=2;
7344 82 tempitem.wpn=wARROW;
7345 82 break;
7346
7347 case iHoverBoots:
7348 82 tempitem.misc1=45;
7349 82 tempitem.wpn=iwHover;
7350 82 break;
7351
7352 case iDivineFire:
7353 82 tempitem.power=8;
7354 82 tempitem.wpn=wDIVINEFIRE1A;
7355 82 tempitem.wpn2=wDIVINEFIRE1B;
7356 82 tempitem.wpn3=wDIVINEFIRES1A;
7357 82 tempitem.wpn4=wDIVINEFIRES1B;
7358 82 tempitem.misc1 = 32;
7359 82 tempitem.misc2 = 200;
7360 82 tempitem.cost_amount[0]=32;
7361 82 break;
7362
7363 case iDivineEscape:
7364 82 tempitem.cost_amount[0]=32;
7365 82 break;
7366
7367 case iHookshot:
7368 82 tempitem.power=0;
7369 82 tempitem.flags&=~item_flag1;
7370 82 tempitem.wpn=wHSHEAD;
7371 82 tempitem.wpn2=wHSCHAIN_H;
7372 82 tempitem.wpn4=wHSHANDLE;
7373 82 tempitem.wpn3=wHSCHAIN_V;
7374 82 tempitem.misc1=50;
7375 82 tempitem.misc2=100;
7376 82 break;
7377
7378 case iLongshot:
7379 82 tempitem.power=0;
7380 82 tempitem.flags&=~item_flag1;
7381 82 tempitem.wpn=wLSHEAD;
7382 82 tempitem.wpn2=wLSCHAIN_H;
7383 82 tempitem.wpn4=wLSHANDLE;
7384 82 tempitem.wpn3=wLSCHAIN_V;
7385 82 tempitem.misc1=99;
7386 82 tempitem.misc2=100;
7387 82 break;
7388
7389 case iHammer:
7390 82 tempitem.power=4;
7391 82 tempitem.wpn=wHAMMER;
7392 82 tempitem.wpn2=iwHammerSmack;
7393 82 break;
7394
7395 case iCByrna:
7396 82 tempitem.power=1;
7397 82 tempitem.wpn=wCBYRNA;
7398 82 tempitem.wpn2=wCBYRNASLASH;
7399 82 tempitem.wpn3=wCBYRNAORB;
7400 82 tempitem.misc1=4;
7401 82 tempitem.misc2=16;
7402 82 tempitem.misc3=1;
7403 82 tempitem.cost_amount[0]=1;
7404 82 break;
7405
7406 case iWhistle:
7407 82 tempitem.wpn=wWIND;
7408 82 tempitem.misc1=3;
7409 82 tempitem.flags|=item_flag1;
7410 82 break;
7411
7412 case iBRing:
7413 82 tempitem.power=2;
7414 82 tempitem.misc1=spBLUE;
7415 82 break;
7416
7417 case iRRing:
7418 82 tempitem.power=4;
7419 82 tempitem.misc1=spRED;
7420 82 break;
7421
7422 case iGRing:
7423 82 tempitem.power=8;
7424 82 tempitem.misc1=spGOLD;
7425 82 break;
7426
7427 case iSpinScroll:
7428 82 tempitem.power = 2;
7429 82 tempitem.misc1 = 1;
7430 82 break;
7431
7432 case iL2SpinScroll:
7433 82 tempitem.family=itype_spinscroll2;
7434 82 tempitem.fam_type=1;
7435 82 tempitem.cost_amount[0]=8;
7436 82 tempitem.power=2;
7437 82 tempitem.misc1 = 20;
7438 82 break;
7439
7440 case iQuakeScroll:
7441 82 tempitem.misc1=0x10;
7442 82 tempitem.misc2=64;
7443 82 break;
7444
7445 case iL2QuakeScroll:
7446 82 tempitem.family=itype_quakescroll2;
7447 82 tempitem.fam_type=1;
7448 82 tempitem.power = 2;
7449 82 tempitem.misc1=0x20;
7450 82 tempitem.misc2=192;
7451 82 tempitem.cost_amount[0]=8;
7452 82 break;
7453
7454 case iChargeRing:
7455 82 tempitem.misc1=64;
7456 82 tempitem.misc2=128;
7457 82 break;
7458
7459 case iL2ChargeRing:
7460 82 tempitem.misc1=32;
7461 82 tempitem.misc2=64;
7462 82 break;
7463
7464 case iOldGlove:
7465 82 tempitem.flags |= item_flag1;
7466
7467 //fallthrough
7468 case iBombBagL4:
7469 case iWalletL3:
7470 case iQuiverL4:
7471 case iBracelet:
7472 410 tempitem.power = 1;
7473 410 break;
7474
7475 case iL2Bracelet:
7476 82 tempitem.power = 2;
7477 82 break;
7478
7479 case iMKey:
7480 82 tempitem.power=0xFF;
7481 82 tempitem.flags |= item_flag1;
7482 82 break;
7483 }
7484 20992 }
7485
7486
2/2
✓ Branch 0 taken 101888 times.
✓ Branch 1 taken 20992 times.
122880 if(s_version < 7)
7487 {
7488
2/2
✓ Branch 0 taken 328 times.
✓ Branch 1 taken 20664 times.
20992 switch(i)
7489 {
7490 case iStoneAgony:
7491 case iStompBoots:
7492 case iPerilRing:
7493 case iWhimsicalRing:
7494 {
7495 328 reset_itembuf(&tempitem, i);
7496 328 strcpy(item_string[i],old_item_string[i]);
7497 328 break;
7498 }
7499 }
7500 20992 }
7501
7502
2/2
✓ Branch 0 taken 101888 times.
✓ Branch 1 taken 20992 times.
122880 if(s_version < 8) // May 2007: Some corrections.
7503 {
7504
7/7
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 246 times.
✓ Branch 2 taken 20336 times.
✓ Branch 3 taken 82 times.
✓ Branch 4 taken 82 times.
✓ Branch 5 taken 82 times.
✓ Branch 6 taken 82 times.
20992 switch(i)
7505 {
7506 case iMShield:
7507 82 tempitem.misc1|=sh_flame;
7508 82 tempitem.misc2|=sh_fireball|sh_magic;
7509
7510
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if(get_qr(qr_SWORDMIRROR))
7511 {
7512 tempitem.misc2 |= sh_sword;
7513 }
7514
7515 // fallthrough
7516 case iShield:
7517 164 tempitem.misc1|=sh_fireball|sh_sword|sh_magic;
7518
7519 // fallthrough
7520 case iSShield:
7521 246 tempitem.misc1|=sh_rock|sh_arrow|sh_brang|sh_script;
7522
7523
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 246 times.
246 if(get_bit(deprecated_rules,102)) //qr_REFLECTROCKS
7524 {
7525 tempitem.misc2 |= sh_rock;
7526 }
7527
7528 246 break;
7529
7530 case iWhispRing:
7531 82 tempitem.power=1;
7532 82 tempitem.flags|=item_gamedata|item_flag1;
7533 82 tempitem.misc1 = 3;
7534 82 break;
7535
7536 case iL2WhispRing:
7537 82 tempitem.power=0;
7538 82 tempitem.flags|=item_gamedata|item_flag1;
7539 82 tempitem.misc1 = 3;
7540 82 break;
7541
7542 case iL2Ladder:
7543 case iBow:
7544 case iCByrna:
7545 246 tempitem.power = 1;
7546 246 break;
7547 }
7548 20992 }
7549
7550
4/4
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 101888 times.
✓ Branch 2 taken 20910 times.
✓ Branch 3 taken 82 times.
122880 if(s_version < 9 && i==iClock)
7551 {
7552 82 tempitem.misc1 = get_bit(deprecated_rules, qr_TEMPCLOCKS_DEP) ? 256 : 0;
7553 82 }
7554
7555 //add the misc flag for bomb
7556
4/4
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 101888 times.
✓ Branch 2 taken 20910 times.
✓ Branch 3 taken 82 times.
122880 if(s_version < 10 && tempitem.family == itype_bomb)
7557 {
7558 82 tempitem.flags = (tempitem.flags & ~item_flag1) | (get_qr(qr_LONGBOMBBOOM_DEP) ? item_flag1 : item_none);
7559 82 }
7560
7561
4/4
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 101888 times.
✓ Branch 2 taken 20828 times.
✓ Branch 3 taken 164 times.
122880 if(s_version < 11 && tempitem.family == itype_triforcepiece)
7562 {
7563 164 tempitem.flags = (tempitem.fam_type ? item_gamedata : item_none);
7564 164 tempitem.playsound = (tempitem.fam_type ? WAV_SCALE : WAV_CLEARED);
7565 164 }
7566
7567
2/2
✓ Branch 0 taken 101888 times.
✓ Branch 1 taken 20992 times.
122880 if(s_version < 12) // June 2007: More Misc. attributes.
7568 {
7569
5/5
✓ Branch 0 taken 164 times.
✓ Branch 1 taken 20582 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 82 times.
✓ Branch 4 taken 82 times.
20992 switch(i)
7570 {
7571 case iFBrang:
7572 82 tempitem.misc4 |= sh_fireball|sh_sword|sh_magic;
7573
7574 //fallthrough
7575 case iMBrang:
7576 164 tempitem.misc3 |= sh_sword|sh_magic;
7577
7578 //fallthrough
7579 case iHookshot:
7580 case iLongshot:
7581 //fallthrough
7582 328 tempitem.misc3 |= sh_fireball;
7583
7584 case iBrang:
7585 410 tempitem.misc3 |= sh_brang|sh_rock|sh_arrow;
7586 410 break;
7587 }
7588
7589
16/16
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 246 times.
✓ Branch 3 taken 246 times.
✓ Branch 4 taken 82 times.
✓ Branch 5 taken 82 times.
✓ Branch 6 taken 82 times.
✓ Branch 7 taken 328 times.
✓ Branch 8 taken 164 times.
✓ Branch 9 taken 9629 times.
✓ Branch 10 taken 82 times.
✓ Branch 11 taken 164 times.
✓ Branch 12 taken 246 times.
✓ Branch 13 taken 9313 times.
✓ Branch 14 taken 82 times.
✓ Branch 15 taken 82 times.
20992 switch(tempitem.family)
7590 {
7591 case itype_hoverboots:
7592 82 tempitem.usesound = WAV_ZN1HOVER;
7593 82 break;
7594
7595 case itype_wand:
7596 82 tempitem.usesound = WAV_WAND;
7597 82 break;
7598
7599 case itype_book:
7600 82 tempitem.usesound = WAV_FIRE;
7601 82 break;
7602
7603 case itype_arrow:
7604 246 tempitem.usesound = WAV_ARROW;
7605 246 break;
7606
7607 case itype_hookshot:
7608 164 tempitem.usesound = WAV_HOOKSHOT;
7609 164 break;
7610
7611 case itype_brang:
7612 246 tempitem.usesound = WAV_BRANG;
7613 246 break;
7614
7615 case itype_shield:
7616 246 tempitem.usesound = WAV_CHINK;
7617 246 break;
7618
7619 case itype_sword:
7620 9313 tempitem.usesound = WAV_SWORD;
7621 9313 break;
7622
7623 case itype_whistle:
7624 82 tempitem.usesound = WAV_WHISTLE;
7625 82 break;
7626
7627 case itype_hammer:
7628 82 tempitem.usesound = WAV_HAMMER;
7629 82 break;
7630
7631 case itype_divinefire:
7632 82 tempitem.usesound = WAV_ZN1DIVINEFIRE;
7633 82 break;
7634
7635 case itype_divineescape:
7636 82 tempitem.usesound = WAV_ZN1DIVINEESCAPE;
7637 82 break;
7638
7639 case itype_divineprotection:
7640 82 tempitem.usesound = WAV_ZN1DIVINEPROTECTION1;
7641 82 break;
7642
7643 case itype_bomb:
7644 case itype_sbomb:
7645 case itype_quakescroll:
7646 case itype_quakescroll2:
7647 328 tempitem.usesound = WAV_BOMB;
7648 328 break;
7649
7650 case itype_spinscroll:
7651 case itype_spinscroll2:
7652 164 tempitem.usesound = WAV_ZN1SPINATTACK;
7653 164 break;
7654 }
7655 20992 }
7656
7657
2/2
✓ Branch 0 taken 101888 times.
✓ Branch 1 taken 20992 times.
122880 if(s_version < 13) // July 2007
7658 {
7659
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 20910 times.
20992 if(tempitem.family == itype_whistle)
7660 {
7661 82 tempitem.misc1 = (tempitem.power==2 ? 4 : 3);
7662 82 tempitem.power = 1;
7663 82 tempitem.flags|=item_flag1;
7664 82 }
7665
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 20828 times.
20910 else if(tempitem.family == itype_wand)
7666 82 tempitem.flags|=item_flag1;
7667
2/2
✓ Branch 0 taken 20746 times.
✓ Branch 1 taken 82 times.
20828 else if(tempitem.family == itype_book)
7668 {
7669 82 tempitem.flags|=item_flag1;
7670 82 tempitem.power = 2;
7671 82 }
7672 20992 }
7673
7674
2/2
✓ Branch 0 taken 101888 times.
✓ Branch 1 taken 20992 times.
122880 if(s_version < 14) // August 2007
7675 {
7676
2/2
✓ Branch 0 taken 164 times.
✓ Branch 1 taken 20828 times.
20992 if(tempitem.family == itype_fairy)
7677 {
7678 164 tempitem.usesound = WAV_SCALE;
7679
7680
1/2
✓ Branch 0 taken 164 times.
✗ Branch 1 not taken.
164 if(tempitem.fam_type)
7681 164 tempitem.misc3=50;
7682 164 }
7683
2/2
✓ Branch 0 taken 20664 times.
✓ Branch 1 taken 164 times.
20828 else if(tempitem.family == itype_potion)
7684 {
7685 164 tempitem.flags |= item_gain_old;
7686 164 }
7687 20992 }
7688
7689
2/2
✓ Branch 0 taken 101888 times.
✓ Branch 1 taken 20992 times.
122880 if(s_version < 17) // November 2007
7690 {
7691
3/4
✓ Branch 0 taken 164 times.
✓ Branch 1 taken 20828 times.
✓ Branch 2 taken 164 times.
✗ Branch 3 not taken.
20992 if(tempitem.family == itype_candle && !tempitem.wpn3)
7692 {
7693 tempitem.wpn3 = wFIRE;
7694 }
7695
4/4
✓ Branch 0 taken 246 times.
✓ Branch 1 taken 20746 times.
✓ Branch 2 taken 164 times.
✓ Branch 3 taken 82 times.
20992 else if(tempitem.family == itype_arrow && tempitem.power>4)
7696 {
7697 82 tempitem.flags|=item_flag1;
7698 82 }
7699 20992 }
7700
7701
2/2
✓ Branch 0 taken 101888 times.
✓ Branch 1 taken 20992 times.
122880 if(s_version < 18) // New Year's Eve 2007
7702 {
7703
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 20910 times.
20992 if(tempitem.family == itype_whistle)
7704 82 tempitem.misc2 = 8; // Use the Whistle warp ring
7705
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 20828 times.
20910 else if(tempitem.family == itype_bait)
7706 82 tempitem.misc1 = 768; // Frames until it goes
7707
2/2
✓ Branch 0 taken 20664 times.
✓ Branch 1 taken 164 times.
20828 else if(tempitem.family == itype_triforcepiece)
7708 {
7709
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 82 times.
164 if(tempitem.flags & item_gamedata)
7710 {
7711 82 tempitem.misc2 = 1; // Cutscene 1
7712 82 tempitem.flags |= item_flag1; // Side Warp Out
7713 82 }
7714 164 }
7715 20992 }
7716
7717
2/2
✓ Branch 0 taken 101888 times.
✓ Branch 1 taken 20992 times.
122880 if(s_version < 19) // January 2008
7718 {
7719
2/2
✓ Branch 0 taken 20910 times.
✓ Branch 1 taken 82 times.
20992 if(tempitem.family == itype_divineprotection)
7720 {
7721
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 80 times.
82 if (get_bit(deprecated_rules,qr_NOBOMBPALFLASH+1)) tempitem.flags |= item_flag3;
7722
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 72 times.
82 if (get_bit(deprecated_rules,qr_NOBOMBPALFLASH+2)) tempitem.flags |= item_flag4;
7723 82 }
7724 20992 }
7725
7726
2/2
✓ Branch 0 taken 101888 times.
✓ Branch 1 taken 20992 times.
122880 if(s_version < 20) // October 2008
7727 {
7728
2/2
✓ Branch 0 taken 20910 times.
✓ Branch 1 taken 82 times.
20992 if(tempitem.family == itype_divineprotection)
7729 {
7730 82 tempitem.wpn6=wDIVINEPROTECTION2A;
7731 82 tempitem.wpn7=wDIVINEPROTECTION2B;
7732 82 tempitem.wpn8=wDIVINEPROTECTIONS2A;
7733 82 tempitem.wpn9=wDIVINEPROTECTIONS2B;
7734 82 tempitem.wpn5 = iwDivineProtectionShieldFront;
7735 82 tempitem.wpn10 = iwDivineProtectionShieldBack;
7736 82 }
7737 20992 }
7738
7739
2/2
✓ Branch 0 taken 101888 times.
✓ Branch 1 taken 20992 times.
122880 if(s_version < 21) // November 2008
7740 {
7741
1/2
✓ Branch 0 taken 20992 times.
✗ Branch 1 not taken.
20992 if(tempitem.flags & 0x0100) // item_slash
7742 {
7743 tempitem.flags &= ~item_unused;
7744
7745 if(tempitem.family == itype_sword ||
7746 tempitem.family == itype_wand ||
7747 tempitem.family == itype_candle ||
7748 tempitem.family == itype_cbyrna)
7749 {
7750 tempitem.flags |= item_flag4;
7751 }
7752 }
7753 20992 }
7754
7755
2/2
✓ Branch 0 taken 101888 times.
✓ Branch 1 taken 20992 times.
122880 if(s_version < 22) // September 2009
7756 {
7757
4/4
✓ Branch 0 taken 20910 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 20828 times.
20992 if(tempitem.family == itype_sbomb || tempitem.family == itype_bomb)
7758 {
7759 164 tempitem.misc3 = tempitem.power/2;
7760 164 }
7761 20992 }
7762
7763
2/2
✓ Branch 0 taken 101888 times.
✓ Branch 1 taken 20992 times.
122880 if(s_version < 23) // March 2011
7764 {
7765
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 20910 times.
20992 if(tempitem.family == itype_divinefire)
7766 82 tempitem.wpn5 = wFIRE;
7767
2/2
✓ Branch 0 taken 20828 times.
✓ Branch 1 taken 82 times.
20910 else if(tempitem.family == itype_book)
7768 82 tempitem.wpn2 = wFIRE;
7769 20992 }
7770
7771 // Version 25: Bomb bags were acting as though "super bombs also" was checked
7772 // whether it was or not, and a lot of existing quests depended on the
7773 // incorrect behavior.
7774
2/2
✓ Branch 0 taken 101888 times.
✓ Branch 1 taken 20992 times.
122880 if(s_version < 25) // January 2012
7775 {
7776
2/2
✓ Branch 0 taken 20664 times.
✓ Branch 1 taken 328 times.
20992 if(tempitem.family == itype_bombbag)
7777 328 tempitem.flags |= item_flag1;
7778
7779
2/2
✓ Branch 0 taken 20910 times.
✓ Branch 1 taken 82 times.
20992 if(tempitem.family == itype_divinefire)
7780 82 tempitem.flags |= item_flag3; // Sideview gravity flag
7781 20992 }
7782
7783
2/2
✓ Branch 0 taken 49152 times.
✓ Branch 1 taken 73728 times.
122880 if( version < 0x254) //Nuke greyed-out flags/values from <=2.53, in case they are used in 2.54/2.55
7784 {
7785
60/60
✓ Branch 0 taken 17692 times.
✓ Branch 1 taken 862 times.
✓ Branch 2 taken 847 times.
✓ Branch 3 taken 612 times.
✓ Branch 4 taken 333 times.
✓ Branch 5 taken 288 times.
✓ Branch 6 taken 570 times.
✓ Branch 7 taken 625 times.
✓ Branch 8 taken 303 times.
✓ Branch 9 taken 935 times.
✓ Branch 10 taken 910 times.
✓ Branch 11 taken 567 times.
✓ Branch 12 taken 876 times.
✓ Branch 13 taken 570 times.
✓ Branch 14 taken 285 times.
✓ Branch 15 taken 570 times.
✓ Branch 16 taken 301 times.
✓ Branch 17 taken 285 times.
✓ Branch 18 taken 864 times.
✓ Branch 19 taken 288 times.
✓ Branch 20 taken 291 times.
✓ Branch 21 taken 572 times.
✓ Branch 22 taken 261 times.
✓ Branch 23 taken 288 times.
✓ Branch 24 taken 285 times.
✓ Branch 25 taken 285 times.
✓ Branch 26 taken 285 times.
✓ Branch 27 taken 301 times.
✓ Branch 28 taken 287 times.
✓ Branch 29 taken 288 times.
✓ Branch 30 taken 285 times.
✓ Branch 31 taken 290 times.
✓ Branch 32 taken 570 times.
✓ Branch 33 taken 1140 times.
✓ Branch 34 taken 786 times.
✓ Branch 35 taken 285 times.
✓ Branch 36 taken 557 times.
✓ Branch 37 taken 1140 times.
✓ Branch 38 taken 285 times.
✓ Branch 39 taken 285 times.
✓ Branch 40 taken 285 times.
✓ Branch 41 taken 285 times.
✓ Branch 42 taken 285 times.
✓ Branch 43 taken 573 times.
✓ Branch 44 taken 570 times.
✓ Branch 45 taken 285 times.
✓ Branch 46 taken 858 times.
✓ Branch 47 taken 861 times.
✓ Branch 48 taken 1152 times.
✓ Branch 49 taken 285 times.
✓ Branch 50 taken 285 times.
✓ Branch 51 taken 285 times.
✓ Branch 52 taken 285 times.
✓ Branch 53 taken 285 times.
✓ Branch 54 taken 312 times.
✓ Branch 55 taken 11134 times.
✓ Branch 56 taken 2933 times.
✓ Branch 57 taken 860 times.
✓ Branch 58 taken 3328 times.
✓ Branch 59 taken 11233 times.
73728 switch(tempitem.family)
7786 {
7787 case itype_sword:
7788 {
7789 17692 tempitem.flags &= ~(item_flag5);
7790 17692 tempitem.misc3 = 0;
7791 17692 tempitem.misc4 = 0;
7792 17692 tempitem.misc5 = 0;
7793 17692 tempitem.misc6 = 0;
7794 17692 tempitem.misc7 = 0;
7795 17692 tempitem.misc8 = 0;
7796 17692 tempitem.misc9 = 0;
7797 17692 tempitem.misc10 = 0;
7798 17692 tempitem.wpn4 = 0;
7799 17692 tempitem.wpn5 = 0;
7800 17692 tempitem.wpn6 = 0;
7801 17692 tempitem.wpn7 = 0;
7802 17692 tempitem.wpn8 = 0;
7803 17692 tempitem.wpn9 = 0;
7804 17692 tempitem.wpn10 = 0;
7805 17692 break;
7806 }
7807 case itype_brang:
7808 {
7809 862 tempitem.flags &= ~(item_flag4 | item_flag5);
7810 862 tempitem.misc2 = 0;
7811 862 tempitem.misc5 = 0;
7812 862 tempitem.misc6 = 0;
7813 862 tempitem.misc7 = 0;
7814 862 tempitem.misc8 = 0;
7815 862 tempitem.misc9 = 0;
7816 862 tempitem.misc10 = 0;
7817 862 tempitem.wpn4 = 0;
7818 862 tempitem.wpn5 = 0;
7819 862 tempitem.wpn6 = 0;
7820 862 tempitem.wpn7 = 0;
7821 862 tempitem.wpn8 = 0;
7822 862 tempitem.wpn9 = 0;
7823 862 tempitem.wpn10 = 0;
7824 862 break;
7825 }
7826 case itype_arrow:
7827 {
7828 847 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
7829 847 tempitem.misc2 = 0;
7830 847 tempitem.misc3 = 0;
7831 847 tempitem.misc4 = 0;
7832 847 tempitem.misc5 = 0;
7833 847 tempitem.misc6 = 0;
7834 847 tempitem.misc7 = 0;
7835 847 tempitem.misc8 = 0;
7836 847 tempitem.misc9 = 0;
7837 847 tempitem.misc10 = 0;
7838 847 tempitem.wpn4 = 0;
7839 847 tempitem.wpn5 = 0;
7840 847 tempitem.wpn6 = 0;
7841 847 tempitem.wpn7 = 0;
7842 847 tempitem.wpn8 = 0;
7843 847 tempitem.wpn9 = 0;
7844 847 tempitem.wpn10 = 0;
7845 847 break;
7846 }
7847 case itype_candle:
7848 {
7849 612 tempitem.flags &= ~ (item_flag3 | item_flag5);
7850 612 tempitem.misc1 = 0;
7851 612 tempitem.misc2 = 0;
7852 612 tempitem.misc3 = 0;
7853 612 tempitem.misc4 = 0;
7854 612 tempitem.misc5 = 0;
7855 612 tempitem.misc6 = 0;
7856 612 tempitem.misc7 = 0;
7857 612 tempitem.misc8 = 0;
7858 612 tempitem.misc9 = 0;
7859 612 tempitem.misc10 = 0;
7860 612 tempitem.wpn4 = 0;
7861 612 tempitem.wpn5 = 0;
7862 612 tempitem.wpn6 = 0;
7863 612 tempitem.wpn7 = 0;
7864 612 tempitem.wpn8 = 0;
7865 612 tempitem.wpn9 = 0;
7866 612 tempitem.wpn10 = 0;
7867 612 break;
7868 }
7869 case itype_whistle:
7870 {
7871 333 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
7872 333 tempitem.misc3 = 0;
7873 333 tempitem.misc4 = 0;
7874 333 tempitem.misc5 = 0;
7875 333 tempitem.misc6 = 0;
7876 333 tempitem.misc7 = 0;
7877 333 tempitem.misc8 = 0;
7878 333 tempitem.misc9 = 0;
7879 333 tempitem.misc10 = 0;
7880 333 tempitem.wpn2 = 0;
7881 333 tempitem.wpn3 = 0;
7882 333 tempitem.wpn4 = 0;
7883 333 tempitem.wpn5 = 0;
7884 333 tempitem.wpn6 = 0;
7885 333 tempitem.wpn7 = 0;
7886 333 tempitem.wpn8 = 0;
7887 333 tempitem.wpn9 = 0;
7888 333 tempitem.wpn10 = 0;
7889 333 break;
7890 }
7891 case itype_bait:
7892 {
7893 288 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
7894 288 tempitem.misc2 = 0;
7895 288 tempitem.misc3 = 0;
7896 288 tempitem.misc4 = 0;
7897 288 tempitem.misc5 = 0;
7898 288 tempitem.misc6 = 0;
7899 288 tempitem.misc7 = 0;
7900 288 tempitem.misc8 = 0;
7901 288 tempitem.misc9 = 0;
7902 288 tempitem.misc10 = 0;
7903 288 tempitem.wpn2 = 0;
7904 288 tempitem.wpn3 = 0;
7905 288 tempitem.wpn4 = 0;
7906 288 tempitem.wpn5 = 0;
7907 288 tempitem.wpn6 = 0;
7908 288 tempitem.wpn7 = 0;
7909 288 tempitem.wpn8 = 0;
7910 288 tempitem.wpn9 = 0;
7911 288 tempitem.wpn10 = 0;
7912 288 break;
7913 }
7914 case itype_letter:
7915 {
7916 570 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
7917 570 tempitem.misc1 = 0;
7918 570 tempitem.misc2 = 0;
7919 570 tempitem.misc3 = 0;
7920 570 tempitem.misc4 = 0;
7921 570 tempitem.misc5 = 0;
7922 570 tempitem.misc6 = 0;
7923 570 tempitem.misc7 = 0;
7924 570 tempitem.misc8 = 0;
7925 570 tempitem.misc9 = 0;
7926 570 tempitem.misc10 = 0;
7927 570 tempitem.wpn = 0;
7928 570 tempitem.wpn2 = 0;
7929 570 tempitem.wpn3 = 0;
7930 570 tempitem.wpn4 = 0;
7931 570 tempitem.wpn5 = 0;
7932 570 tempitem.wpn6 = 0;
7933 570 tempitem.wpn7 = 0;
7934 570 tempitem.wpn8 = 0;
7935 570 tempitem.wpn9 = 0;
7936 570 tempitem.wpn10 = 0;
7937 570 break;
7938 }
7939 case itype_potion:
7940 {
7941 625 tempitem.flags &= ~ (item_flag3 | item_flag4 | item_flag5);
7942 625 tempitem.misc3 = 0;
7943 625 tempitem.misc4 = 0;
7944 625 tempitem.misc5 = 0;
7945 625 tempitem.misc6 = 0;
7946 625 tempitem.misc7 = 0;
7947 625 tempitem.misc8 = 0;
7948 625 tempitem.misc9 = 0;
7949 625 tempitem.misc10 = 0;
7950 625 tempitem.wpn = 0;
7951 625 tempitem.wpn2 = 0;
7952 625 tempitem.wpn3 = 0;
7953 625 tempitem.wpn4 = 0;
7954 625 tempitem.wpn5 = 0;
7955 625 tempitem.wpn6 = 0;
7956 625 tempitem.wpn7 = 0;
7957 625 tempitem.wpn8 = 0;
7958 625 tempitem.wpn9 = 0;
7959 625 tempitem.wpn10 = 0;
7960 625 break;
7961 }
7962 case itype_wand:
7963 {
7964 303 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag5);
7965 303 tempitem.misc1 = 0;
7966 303 tempitem.misc2 = 0;
7967 303 tempitem.misc3 = 0;
7968 303 tempitem.misc4 = 0;
7969 303 tempitem.misc5 = 0;
7970 303 tempitem.misc6 = 0;
7971 303 tempitem.misc7 = 0;
7972 303 tempitem.misc8 = 0;
7973 303 tempitem.misc9 = 0;
7974 303 tempitem.misc10 = 0;
7975 303 tempitem.wpn4 = 0;
7976 303 tempitem.wpn5 = 0;
7977 303 tempitem.wpn6 = 0;
7978 303 tempitem.wpn7 = 0;
7979 303 tempitem.wpn8 = 0;
7980 303 tempitem.wpn9 = 0;
7981 303 tempitem.wpn10 = 0;
7982 303 break;
7983 }
7984 case itype_ring:
7985 {
7986 935 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
7987 935 tempitem.misc2 = 0;
7988 935 tempitem.misc3 = 0;
7989 935 tempitem.misc4 = 0;
7990 935 tempitem.misc5 = 0;
7991 935 tempitem.misc6 = 0;
7992 935 tempitem.misc7 = 0;
7993 935 tempitem.misc8 = 0;
7994 935 tempitem.misc9 = 0;
7995 935 tempitem.misc10 = 0;
7996 935 tempitem.wpn = 0;
7997 935 tempitem.wpn2 = 0;
7998 935 tempitem.wpn3 = 0;
7999 935 tempitem.wpn4 = 0;
8000 935 tempitem.wpn5 = 0;
8001 935 tempitem.wpn6 = 0;
8002 935 tempitem.wpn7 = 0;
8003 935 tempitem.wpn8 = 0;
8004 935 tempitem.wpn9 = 0;
8005 935 tempitem.wpn10 = 0;
8006 935 break;
8007 }
8008 case itype_wallet:
8009 {
8010 910 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8011 910 tempitem.misc3 = 0;
8012 910 tempitem.misc4 = 0;
8013 910 tempitem.misc5 = 0;
8014 910 tempitem.misc6 = 0;
8015 910 tempitem.misc7 = 0;
8016 910 tempitem.misc8 = 0;
8017 910 tempitem.misc9 = 0;
8018 910 tempitem.misc10 = 0;
8019 910 tempitem.wpn = 0;
8020 910 tempitem.wpn2 = 0;
8021 910 tempitem.wpn3 = 0;
8022 910 tempitem.wpn4 = 0;
8023 910 tempitem.wpn5 = 0;
8024 910 tempitem.wpn6 = 0;
8025 910 tempitem.wpn7 = 0;
8026 910 tempitem.wpn8 = 0;
8027 910 tempitem.wpn9 = 0;
8028 910 tempitem.wpn10 = 0;
8029 910 break;
8030 }
8031 case itype_amulet:
8032 {
8033 567 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8034 567 tempitem.misc1 = 0;
8035 567 tempitem.misc2 = 0;
8036 567 tempitem.misc3 = 0;
8037 567 tempitem.misc4 = 0;
8038 567 tempitem.misc5 = 0;
8039 567 tempitem.misc6 = 0;
8040 567 tempitem.misc7 = 0;
8041 567 tempitem.misc8 = 0;
8042 567 tempitem.misc9 = 0;
8043 567 tempitem.misc10 = 0;
8044 567 tempitem.wpn = 0;
8045 567 tempitem.wpn2 = 0;
8046 567 tempitem.wpn3 = 0;
8047 567 tempitem.wpn4 = 0;
8048 567 tempitem.wpn5 = 0;
8049 567 tempitem.wpn6 = 0;
8050 567 tempitem.wpn7 = 0;
8051 567 tempitem.wpn8 = 0;
8052 567 tempitem.wpn9 = 0;
8053 567 tempitem.wpn10 = 0;
8054 567 break;
8055 }
8056 case itype_shield:
8057 {
8058 876 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8059 876 tempitem.misc3 = 0;
8060 876 tempitem.misc4 = 0;
8061 876 tempitem.misc5 = 0;
8062 876 tempitem.misc6 = 0;
8063 876 tempitem.misc7 = 0;
8064 876 tempitem.misc8 = 0;
8065 876 tempitem.misc9 = 0;
8066 876 tempitem.misc10 = 0;
8067 876 tempitem.wpn = 0;
8068 876 tempitem.wpn2 = 0;
8069 876 tempitem.wpn3 = 0;
8070 876 tempitem.wpn4 = 0;
8071 876 tempitem.wpn5 = 0;
8072 876 tempitem.wpn6 = 0;
8073 876 tempitem.wpn7 = 0;
8074 876 tempitem.wpn8 = 0;
8075 876 tempitem.wpn9 = 0;
8076 876 tempitem.wpn10 = 0;
8077 876 break;
8078 }
8079 case itype_bow:
8080 {
8081 570 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8082 570 tempitem.misc1 = 0;
8083 570 tempitem.misc2 = 0;
8084 570 tempitem.misc3 = 0;
8085 570 tempitem.misc4 = 0;
8086 570 tempitem.misc5 = 0;
8087 570 tempitem.misc6 = 0;
8088 570 tempitem.misc7 = 0;
8089 570 tempitem.misc8 = 0;
8090 570 tempitem.misc9 = 0;
8091 570 tempitem.misc10 = 0;
8092 570 tempitem.wpn = 0;
8093 570 tempitem.wpn2 = 0;
8094 570 tempitem.wpn3 = 0;
8095 570 tempitem.wpn4 = 0;
8096 570 tempitem.wpn5 = 0;
8097 570 tempitem.wpn6 = 0;
8098 570 tempitem.wpn7 = 0;
8099 570 tempitem.wpn8 = 0;
8100 570 tempitem.wpn9 = 0;
8101 570 tempitem.wpn10 = 0;
8102 570 break;
8103 }
8104 case itype_raft:
8105 {
8106 285 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8107 285 tempitem.misc1 = 0;
8108 285 tempitem.misc2 = 0;
8109 285 tempitem.misc3 = 0;
8110 285 tempitem.misc4 = 0;
8111 285 tempitem.misc5 = 0;
8112 285 tempitem.misc6 = 0;
8113 285 tempitem.misc7 = 0;
8114 285 tempitem.misc8 = 0;
8115 285 tempitem.misc9 = 0;
8116 285 tempitem.misc10 = 0;
8117 285 tempitem.wpn = 0;
8118 285 tempitem.wpn2 = 0;
8119 285 tempitem.wpn3 = 0;
8120 285 tempitem.wpn4 = 0;
8121 285 tempitem.wpn5 = 0;
8122 285 tempitem.wpn6 = 0;
8123 285 tempitem.wpn7 = 0;
8124 285 tempitem.wpn8 = 0;
8125 285 tempitem.wpn9 = 0;
8126 285 tempitem.wpn10 = 0;
8127 285 break;
8128 }
8129 case itype_ladder:
8130 {
8131 570 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8132 570 tempitem.misc1 = 0;
8133 570 tempitem.misc2 = 0;
8134 570 tempitem.misc3 = 0;
8135 570 tempitem.misc4 = 0;
8136 570 tempitem.misc5 = 0;
8137 570 tempitem.misc6 = 0;
8138 570 tempitem.misc7 = 0;
8139 570 tempitem.misc8 = 0;
8140 570 tempitem.misc9 = 0;
8141 570 tempitem.misc10 = 0;
8142 570 tempitem.wpn = 0;
8143 570 tempitem.wpn2 = 0;
8144 570 tempitem.wpn3 = 0;
8145 570 tempitem.wpn4 = 0;
8146 570 tempitem.wpn5 = 0;
8147 570 tempitem.wpn6 = 0;
8148 570 tempitem.wpn7 = 0;
8149 570 tempitem.wpn8 = 0;
8150 570 tempitem.wpn9 = 0;
8151 570 tempitem.wpn10 = 0;
8152 570 break;
8153 }
8154 case itype_book:
8155 {
8156 301 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8157 301 tempitem.misc1 = 0;
8158 301 tempitem.misc2 = 0;
8159 301 tempitem.misc3 = 0;
8160 301 tempitem.misc4 = 0;
8161 301 tempitem.misc5 = 0;
8162 301 tempitem.misc6 = 0;
8163 301 tempitem.misc7 = 0;
8164 301 tempitem.misc8 = 0;
8165 301 tempitem.misc9 = 0;
8166 301 tempitem.misc10 = 0;
8167 301 tempitem.wpn3 = 0;
8168 301 tempitem.wpn4 = 0;
8169 301 tempitem.wpn5 = 0;
8170 301 tempitem.wpn6 = 0;
8171 301 tempitem.wpn7 = 0;
8172 301 tempitem.wpn8 = 0;
8173 301 tempitem.wpn9 = 0;
8174 301 tempitem.wpn10 = 0;
8175 301 break;
8176 }
8177 case itype_magickey:
8178 {
8179 285 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8180 285 tempitem.misc1 = 0;
8181 285 tempitem.misc2 = 0;
8182 285 tempitem.misc3 = 0;
8183 285 tempitem.misc4 = 0;
8184 285 tempitem.misc5 = 0;
8185 285 tempitem.misc6 = 0;
8186 285 tempitem.misc7 = 0;
8187 285 tempitem.misc8 = 0;
8188 285 tempitem.misc9 = 0;
8189 285 tempitem.misc10 = 0;
8190 285 tempitem.wpn = 0;
8191 285 tempitem.wpn2 = 0;
8192 285 tempitem.wpn3 = 0;
8193 285 tempitem.wpn4 = 0;
8194 285 tempitem.wpn5 = 0;
8195 285 tempitem.wpn6 = 0;
8196 285 tempitem.wpn7 = 0;
8197 285 tempitem.wpn8 = 0;
8198 285 tempitem.wpn9 = 0;
8199 285 tempitem.wpn10 = 0;
8200 285 break;
8201 }
8202 case itype_bracelet:
8203 {
8204 864 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8205 864 tempitem.misc1 = 0;
8206 864 tempitem.misc2 = 0;
8207 864 tempitem.misc3 = 0;
8208 864 tempitem.misc4 = 0;
8209 864 tempitem.misc5 = 0;
8210 864 tempitem.misc6 = 0;
8211 864 tempitem.misc7 = 0;
8212 864 tempitem.misc8 = 0;
8213 864 tempitem.misc9 = 0;
8214 864 tempitem.misc10 = 0;
8215 864 tempitem.wpn = 0;
8216 864 tempitem.wpn2 = 0;
8217 864 tempitem.wpn3 = 0;
8218 864 tempitem.wpn4 = 0;
8219 864 tempitem.wpn5 = 0;
8220 864 tempitem.wpn6 = 0;
8221 864 tempitem.wpn7 = 0;
8222 864 tempitem.wpn8 = 0;
8223 864 tempitem.wpn9 = 0;
8224 864 tempitem.wpn10 = 0;
8225 864 break;
8226 }
8227 case itype_flippers:
8228 {
8229 288 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8230 288 tempitem.misc1 = 0;
8231 288 tempitem.misc2 = 0;
8232 288 tempitem.misc3 = 0;
8233 288 tempitem.misc4 = 0;
8234 288 tempitem.misc5 = 0;
8235 288 tempitem.misc6 = 0;
8236 288 tempitem.misc7 = 0;
8237 288 tempitem.misc8 = 0;
8238 288 tempitem.misc9 = 0;
8239 288 tempitem.misc10 = 0;
8240 288 tempitem.wpn = 0;
8241 288 tempitem.wpn2 = 0;
8242 288 tempitem.wpn3 = 0;
8243 288 tempitem.wpn4 = 0;
8244 288 tempitem.wpn5 = 0;
8245 288 tempitem.wpn6 = 0;
8246 288 tempitem.wpn7 = 0;
8247 288 tempitem.wpn8 = 0;
8248 288 tempitem.wpn9 = 0;
8249 288 tempitem.wpn10 = 0;
8250 288 break;
8251 }
8252 case itype_boots:
8253 {
8254 291 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8255 291 tempitem.misc1 = 0;
8256 291 tempitem.misc2 = 0;
8257 291 tempitem.misc3 = 0;
8258 291 tempitem.misc4 = 0;
8259 291 tempitem.misc5 = 0;
8260 291 tempitem.misc6 = 0;
8261 291 tempitem.misc7 = 0;
8262 291 tempitem.misc8 = 0;
8263 291 tempitem.misc9 = 0;
8264 291 tempitem.misc10 = 0;
8265 291 tempitem.wpn = 0;
8266 291 tempitem.wpn2 = 0;
8267 291 tempitem.wpn3 = 0;
8268 291 tempitem.wpn4 = 0;
8269 291 tempitem.wpn5 = 0;
8270 291 tempitem.wpn6 = 0;
8271 291 tempitem.wpn7 = 0;
8272 291 tempitem.wpn8 = 0;
8273 291 tempitem.wpn9 = 0;
8274 291 tempitem.wpn10 = 0;
8275 291 break;
8276 }
8277 case itype_hookshot:
8278 {
8279 572 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8280 572 tempitem.misc5 = 0;
8281 572 tempitem.misc6 = 0;
8282 572 tempitem.misc7 = 0;
8283 572 tempitem.misc8 = 0;
8284 572 tempitem.misc9 = 0;
8285 572 tempitem.misc10 = 0;
8286 572 tempitem.wpn5 = 0;
8287 572 tempitem.wpn6 = 0;
8288 572 tempitem.wpn7 = 0;
8289 572 tempitem.wpn8 = 0;
8290 572 tempitem.wpn9 = 0;
8291 572 tempitem.wpn10 = 0;
8292 572 break;
8293 }
8294 case itype_lens:
8295 {
8296 261 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8297 261 tempitem.misc2 = 0;
8298 261 tempitem.misc3 = 0;
8299 261 tempitem.misc4 = 0;
8300 261 tempitem.misc5 = 0;
8301 261 tempitem.misc6 = 0;
8302 261 tempitem.misc7 = 0;
8303 261 tempitem.misc8 = 0;
8304 261 tempitem.misc9 = 0;
8305 261 tempitem.misc10 = 0;
8306 261 tempitem.wpn = 0;
8307 261 tempitem.wpn2 = 0;
8308 261 tempitem.wpn3 = 0;
8309 261 tempitem.wpn4 = 0;
8310 261 tempitem.wpn5 = 0;
8311 261 tempitem.wpn6 = 0;
8312 261 tempitem.wpn7 = 0;
8313 261 tempitem.wpn8 = 0;
8314 261 tempitem.wpn9 = 0;
8315 261 tempitem.wpn10 = 0;
8316 261 break;
8317 }
8318 case itype_hammer:
8319 {
8320 288 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8321 288 tempitem.misc1 = 0;
8322 288 tempitem.misc2 = 0;
8323 288 tempitem.misc3 = 0;
8324 288 tempitem.misc4 = 0;
8325 288 tempitem.misc5 = 0;
8326 288 tempitem.misc6 = 0;
8327 288 tempitem.misc7 = 0;
8328 288 tempitem.misc8 = 0;
8329 288 tempitem.misc9 = 0;
8330 288 tempitem.misc10 = 0;
8331 288 tempitem.wpn3 = 0;
8332 288 tempitem.wpn4 = 0;
8333 288 tempitem.wpn5 = 0;
8334 288 tempitem.wpn6 = 0;
8335 288 tempitem.wpn7 = 0;
8336 288 tempitem.wpn8 = 0;
8337 288 tempitem.wpn9 = 0;
8338 288 tempitem.wpn10 = 0;
8339 288 break;
8340 }
8341 case itype_divinefire:
8342 {
8343 285 tempitem.flags &= ~ (item_flag1 | item_flag4 | item_flag5);
8344 285 tempitem.misc3 = 0;
8345 285 tempitem.misc4 = 0;
8346 285 tempitem.misc5 = 0;
8347 285 tempitem.misc6 = 0;
8348 285 tempitem.misc7 = 0;
8349 285 tempitem.misc8 = 0;
8350 285 tempitem.misc9 = 0;
8351 285 tempitem.misc10 = 0;
8352 285 tempitem.wpn6 = 0;
8353 285 tempitem.wpn7 = 0;
8354 285 tempitem.wpn8 = 0;
8355 285 tempitem.wpn9 = 0;
8356 285 tempitem.wpn10 = 0;
8357 285 break;
8358 }
8359 case itype_divineescape:
8360 {
8361 285 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8362 285 tempitem.misc2 = 0;
8363 285 tempitem.misc3 = 0;
8364 285 tempitem.misc4 = 0;
8365 285 tempitem.misc5 = 0;
8366 285 tempitem.misc6 = 0;
8367 285 tempitem.misc7 = 0;
8368 285 tempitem.misc8 = 0;
8369 285 tempitem.misc9 = 0;
8370 285 tempitem.misc10 = 0;
8371 285 tempitem.wpn = 0;
8372 285 tempitem.wpn2 = 0;
8373 285 tempitem.wpn3 = 0;
8374 285 tempitem.wpn4 = 0;
8375 285 tempitem.wpn5 = 0;
8376 285 tempitem.wpn6 = 0;
8377 285 tempitem.wpn7 = 0;
8378 285 tempitem.wpn8 = 0;
8379 285 tempitem.wpn9 = 0;
8380 285 tempitem.wpn10 = 0;
8381 285 break;
8382 }
8383 case itype_divineprotection:
8384 {
8385 285 tempitem.flags &= ~ (item_flag5);
8386 285 tempitem.misc2 = 0;
8387 285 tempitem.misc3 = 0;
8388 285 tempitem.misc4 = 0;
8389 285 tempitem.misc5 = 0;
8390 285 tempitem.misc6 = 0;
8391 285 tempitem.misc7 = 0;
8392 285 tempitem.misc8 = 0;
8393 285 tempitem.misc9 = 0;
8394 285 tempitem.misc10 = 0;
8395 285 break;
8396 }
8397 case itype_bomb:
8398 {
8399 301 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8400 301 tempitem.misc4 = 0;
8401 301 tempitem.misc5 = 0;
8402 301 tempitem.misc6 = 0;
8403 301 tempitem.misc7 = 0;
8404 301 tempitem.misc8 = 0;
8405 301 tempitem.misc9 = 0;
8406 301 tempitem.misc10 = 0;
8407 301 tempitem.wpn3 = 0;
8408 301 tempitem.wpn4 = 0;
8409 301 tempitem.wpn5 = 0;
8410 301 tempitem.wpn6 = 0;
8411 301 tempitem.wpn7 = 0;
8412 301 tempitem.wpn8 = 0;
8413 301 tempitem.wpn9 = 0;
8414 301 tempitem.wpn10 = 0;
8415 301 break;
8416 }
8417 case itype_sbomb:
8418 {
8419 287 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8420 287 tempitem.misc4 = 0;
8421 287 tempitem.misc5 = 0;
8422 287 tempitem.misc6 = 0;
8423 287 tempitem.misc7 = 0;
8424 287 tempitem.misc8 = 0;
8425 287 tempitem.misc9 = 0;
8426 287 tempitem.misc10 = 0;
8427 287 tempitem.wpn3 = 0;
8428 287 tempitem.wpn4 = 0;
8429 287 tempitem.wpn5 = 0;
8430 287 tempitem.wpn6 = 0;
8431 287 tempitem.wpn7 = 0;
8432 287 tempitem.wpn8 = 0;
8433 287 tempitem.wpn9 = 0;
8434 287 tempitem.wpn10 = 0;
8435 287 break;
8436 }
8437 case itype_clock:
8438 {
8439 288 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8440 288 tempitem.misc2 = 0;
8441 288 tempitem.misc3 = 0;
8442 288 tempitem.misc4 = 0;
8443 288 tempitem.misc5 = 0;
8444 288 tempitem.misc6 = 0;
8445 288 tempitem.misc7 = 0;
8446 288 tempitem.misc8 = 0;
8447 288 tempitem.misc9 = 0;
8448 288 tempitem.misc10 = 0;
8449 288 tempitem.wpn = 0;
8450 288 tempitem.wpn2 = 0;
8451 288 tempitem.wpn3 = 0;
8452 288 tempitem.wpn4 = 0;
8453 288 tempitem.wpn5 = 0;
8454 288 tempitem.wpn6 = 0;
8455 288 tempitem.wpn7 = 0;
8456 288 tempitem.wpn8 = 0;
8457 288 tempitem.wpn9 = 0;
8458 288 tempitem.wpn10 = 0;
8459 288 break;
8460 }
8461 case itype_key:
8462 {
8463 285 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8464 285 tempitem.misc1 = 0;
8465 285 tempitem.misc2 = 0;
8466 285 tempitem.misc3 = 0;
8467 285 tempitem.misc4 = 0;
8468 285 tempitem.misc5 = 0;
8469 285 tempitem.misc6 = 0;
8470 285 tempitem.misc7 = 0;
8471 285 tempitem.misc8 = 0;
8472 285 tempitem.misc9 = 0;
8473 285 tempitem.misc10 = 0;
8474 285 tempitem.wpn = 0;
8475 285 tempitem.wpn2 = 0;
8476 285 tempitem.wpn3 = 0;
8477 285 tempitem.wpn4 = 0;
8478 285 tempitem.wpn5 = 0;
8479 285 tempitem.wpn6 = 0;
8480 285 tempitem.wpn7 = 0;
8481 285 tempitem.wpn8 = 0;
8482 285 tempitem.wpn9 = 0;
8483 285 tempitem.wpn10 = 0;
8484 285 break;
8485 }
8486 case itype_magiccontainer:
8487 {
8488 290 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8489 290 tempitem.misc1 = 0;
8490 290 tempitem.misc2 = 0;
8491 290 tempitem.misc3 = 0;
8492 290 tempitem.misc4 = 0;
8493 290 tempitem.misc5 = 0;
8494 290 tempitem.misc6 = 0;
8495 290 tempitem.misc7 = 0;
8496 290 tempitem.misc8 = 0;
8497 290 tempitem.misc9 = 0;
8498 290 tempitem.misc10 = 0;
8499 290 tempitem.wpn = 0;
8500 290 tempitem.wpn2 = 0;
8501 290 tempitem.wpn3 = 0;
8502 290 tempitem.wpn4 = 0;
8503 290 tempitem.wpn5 = 0;
8504 290 tempitem.wpn6 = 0;
8505 290 tempitem.wpn7 = 0;
8506 290 tempitem.wpn8 = 0;
8507 290 tempitem.wpn9 = 0;
8508 290 tempitem.wpn10 = 0;
8509 290 break;
8510 }
8511 case itype_triforcepiece:
8512 {
8513 570 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8514 570 tempitem.misc3 = 0;
8515 570 tempitem.misc4 = 0;
8516 570 tempitem.misc5 = 0;
8517 570 tempitem.misc6 = 0;
8518 570 tempitem.misc7 = 0;
8519 570 tempitem.misc8 = 0;
8520 570 tempitem.misc9 = 0;
8521 570 tempitem.misc10 = 0;
8522 570 tempitem.wpn = 0;
8523 570 tempitem.wpn2 = 0;
8524 570 tempitem.wpn3 = 0;
8525 570 tempitem.wpn4 = 0;
8526 570 tempitem.wpn5 = 0;
8527 570 tempitem.wpn6 = 0;
8528 570 tempitem.wpn7 = 0;
8529 570 tempitem.wpn8 = 0;
8530 570 tempitem.wpn9 = 0;
8531 570 tempitem.wpn10 = 0;
8532 570 break;
8533 }
8534 case itype_map: case itype_compass: case itype_bosskey:
8535 {
8536 860 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8537 860 tempitem.misc1 = 0;
8538 860 tempitem.misc2 = 0;
8539 860 tempitem.misc3 = 0;
8540 860 tempitem.misc4 = 0;
8541 860 tempitem.misc5 = 0;
8542 860 tempitem.misc6 = 0;
8543 860 tempitem.misc7 = 0;
8544 860 tempitem.misc8 = 0;
8545 860 tempitem.misc9 = 0;
8546 860 tempitem.misc10 = 0;
8547 860 tempitem.wpn = 0;
8548 860 tempitem.wpn2 = 0;
8549 860 tempitem.wpn3 = 0;
8550 860 tempitem.wpn4 = 0;
8551 860 tempitem.wpn5 = 0;
8552 860 tempitem.wpn6 = 0;
8553 860 tempitem.wpn7 = 0;
8554 860 tempitem.wpn8 = 0;
8555 860 tempitem.wpn9 = 0;
8556 860 tempitem.wpn10 = 0;
8557 860 break;
8558 }
8559 case itype_quiver:
8560 {
8561 1140 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8562 1140 tempitem.misc3 = 0;
8563 1140 tempitem.misc4 = 0;
8564 1140 tempitem.misc5 = 0;
8565 1140 tempitem.misc6 = 0;
8566 1140 tempitem.misc7 = 0;
8567 1140 tempitem.misc8 = 0;
8568 1140 tempitem.misc9 = 0;
8569 1140 tempitem.misc10 = 0;
8570 1140 tempitem.wpn = 0;
8571 1140 tempitem.wpn2 = 0;
8572 1140 tempitem.wpn3 = 0;
8573 1140 tempitem.wpn4 = 0;
8574 1140 tempitem.wpn5 = 0;
8575 1140 tempitem.wpn6 = 0;
8576 1140 tempitem.wpn7 = 0;
8577 1140 tempitem.wpn8 = 0;
8578 1140 tempitem.wpn9 = 0;
8579 1140 tempitem.wpn10 = 0;
8580 1140 break;
8581 }
8582 case itype_lkey:
8583 {
8584 786 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8585 786 tempitem.misc1 = 0;
8586 786 tempitem.misc2 = 0;
8587 786 tempitem.misc3 = 0;
8588 786 tempitem.misc4 = 0;
8589 786 tempitem.misc5 = 0;
8590 786 tempitem.misc6 = 0;
8591 786 tempitem.misc7 = 0;
8592 786 tempitem.misc8 = 0;
8593 786 tempitem.misc9 = 0;
8594 786 tempitem.misc10 = 0;
8595 786 tempitem.wpn = 0;
8596 786 tempitem.wpn2 = 0;
8597 786 tempitem.wpn3 = 0;
8598 786 tempitem.wpn4 = 0;
8599 786 tempitem.wpn5 = 0;
8600 786 tempitem.wpn6 = 0;
8601 786 tempitem.wpn7 = 0;
8602 786 tempitem.wpn8 = 0;
8603 786 tempitem.wpn9 = 0;
8604 786 tempitem.wpn10 = 0;
8605 786 break;
8606 }
8607 case itype_cbyrna:
8608 {
8609 285 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag5);
8610 285 tempitem.misc4 = 0;
8611 285 tempitem.misc5 = 0;
8612 285 tempitem.misc6 = 0;
8613 285 tempitem.misc7 = 0;
8614 285 tempitem.misc8 = 0;
8615 285 tempitem.misc9 = 0;
8616 285 tempitem.misc10 = 0;
8617 285 tempitem.wpn6 = 0;
8618 285 tempitem.wpn7 = 0;
8619 285 tempitem.wpn8 = 0;
8620 285 tempitem.wpn9 = 0;
8621 285 tempitem.wpn10 = 0;
8622 285 break;
8623 }
8624 case itype_rupee: case itype_arrowammo:
8625 {
8626 3328 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8627 3328 tempitem.misc1 = 0;
8628 3328 tempitem.misc2 = 0;
8629 3328 tempitem.misc3 = 0;
8630 3328 tempitem.misc4 = 0;
8631 3328 tempitem.misc5 = 0;
8632 3328 tempitem.misc6 = 0;
8633 3328 tempitem.misc7 = 0;
8634 3328 tempitem.misc8 = 0;
8635 3328 tempitem.misc9 = 0;
8636 3328 tempitem.misc10 = 0;
8637 3328 tempitem.wpn = 0;
8638 3328 tempitem.wpn2 = 0;
8639 3328 tempitem.wpn3 = 0;
8640 3328 tempitem.wpn4 = 0;
8641 3328 tempitem.wpn5 = 0;
8642 3328 tempitem.wpn6 = 0;
8643 3328 tempitem.wpn7 = 0;
8644 3328 tempitem.wpn8 = 0;
8645 3328 tempitem.wpn9 = 0;
8646 3328 tempitem.wpn10 = 0;
8647 3328 break;
8648 }
8649 case itype_fairy:
8650 {
8651 557 tempitem.flags &= ~ (item_flag3 | item_flag4 | item_flag5);
8652 557 tempitem.misc4 = 0;
8653 557 tempitem.misc5 = 0;
8654 557 tempitem.misc6 = 0;
8655 557 tempitem.misc7 = 0;
8656 557 tempitem.misc8 = 0;
8657 557 tempitem.misc9 = 0;
8658 557 tempitem.misc10 = 0;
8659 557 tempitem.wpn = 0;
8660 557 tempitem.wpn2 = 0;
8661 557 tempitem.wpn3 = 0;
8662 557 tempitem.wpn4 = 0;
8663 557 tempitem.wpn5 = 0;
8664 557 tempitem.wpn6 = 0;
8665 557 tempitem.wpn7 = 0;
8666 557 tempitem.wpn8 = 0;
8667 557 tempitem.wpn9 = 0;
8668 557 tempitem.wpn10 = 0;
8669 557 break;
8670 }
8671 case itype_magic: case itype_heart: case itype_heartcontainer: case itype_heartpiece: case itype_killem: case itype_bombammo:
8672 {
8673 2933 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8674 2933 tempitem.misc1 = 0;
8675 2933 tempitem.misc2 = 0;
8676 2933 tempitem.misc3 = 0;
8677 2933 tempitem.misc4 = 0;
8678 2933 tempitem.misc5 = 0;
8679 2933 tempitem.misc6 = 0;
8680 2933 tempitem.misc7 = 0;
8681 2933 tempitem.misc8 = 0;
8682 2933 tempitem.misc9 = 0;
8683 2933 tempitem.misc10 = 0;
8684 2933 tempitem.wpn = 0;
8685 2933 tempitem.wpn2 = 0;
8686 2933 tempitem.wpn3 = 0;
8687 2933 tempitem.wpn4 = 0;
8688 2933 tempitem.wpn5 = 0;
8689 2933 tempitem.wpn6 = 0;
8690 2933 tempitem.wpn7 = 0;
8691 2933 tempitem.wpn8 = 0;
8692 2933 tempitem.wpn9 = 0;
8693 2933 tempitem.wpn10 = 0;
8694 2933 break;
8695 }
8696 case itype_bombbag:
8697 {
8698 1140 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8699 1140 tempitem.misc3 = 0;
8700 1140 tempitem.misc4 = 0;
8701 1140 tempitem.misc5 = 0;
8702 1140 tempitem.misc6 = 0;
8703 1140 tempitem.misc7 = 0;
8704 1140 tempitem.misc8 = 0;
8705 1140 tempitem.misc9 = 0;
8706 1140 tempitem.misc10 = 0;
8707 1140 tempitem.wpn = 0;
8708 1140 tempitem.wpn2 = 0;
8709 1140 tempitem.wpn3 = 0;
8710 1140 tempitem.wpn4 = 0;
8711 1140 tempitem.wpn5 = 0;
8712 1140 tempitem.wpn6 = 0;
8713 1140 tempitem.wpn7 = 0;
8714 1140 tempitem.wpn8 = 0;
8715 1140 tempitem.wpn9 = 0;
8716 1140 tempitem.wpn10 = 0;
8717 1140 break;
8718 }
8719 case itype_rocs:
8720 {
8721 285 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8722 285 tempitem.misc1 = 0;
8723 285 tempitem.misc2 = 0;
8724 285 tempitem.misc3 = 0;
8725 285 tempitem.misc4 = 0;
8726 285 tempitem.misc5 = 0;
8727 285 tempitem.misc6 = 0;
8728 285 tempitem.misc7 = 0;
8729 285 tempitem.misc8 = 0;
8730 285 tempitem.misc9 = 0;
8731 285 tempitem.misc10 = 0;
8732 285 tempitem.wpn = 0;
8733 285 tempitem.wpn2 = 0;
8734 285 tempitem.wpn3 = 0;
8735 285 tempitem.wpn4 = 0;
8736 285 tempitem.wpn5 = 0;
8737 285 tempitem.wpn6 = 0;
8738 285 tempitem.wpn7 = 0;
8739 285 tempitem.wpn8 = 0;
8740 285 tempitem.wpn9 = 0;
8741 285 tempitem.wpn10 = 0;
8742 285 break;
8743 }
8744 case itype_hoverboots:
8745 {
8746 285 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8747 285 tempitem.misc2 = 0;
8748 285 tempitem.misc3 = 0;
8749 285 tempitem.misc4 = 0;
8750 285 tempitem.misc5 = 0;
8751 285 tempitem.misc6 = 0;
8752 285 tempitem.misc7 = 0;
8753 285 tempitem.misc8 = 0;
8754 285 tempitem.misc9 = 0;
8755 285 tempitem.misc10 = 0;
8756 285 tempitem.wpn2 = 0;
8757 285 tempitem.wpn3 = 0;
8758 285 tempitem.wpn4 = 0;
8759 285 tempitem.wpn5 = 0;
8760 285 tempitem.wpn6 = 0;
8761 285 tempitem.wpn7 = 0;
8762 285 tempitem.wpn8 = 0;
8763 285 tempitem.wpn9 = 0;
8764 285 tempitem.wpn10 = 0;
8765 285 break;
8766 }
8767 case itype_spinscroll:
8768 {
8769 285 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8770 285 tempitem.misc2 = 0;
8771 285 tempitem.misc3 = 0;
8772 285 tempitem.misc4 = 0;
8773 285 tempitem.misc5 = 0;
8774 285 tempitem.misc6 = 0;
8775 285 tempitem.misc7 = 0;
8776 285 tempitem.misc8 = 0;
8777 285 tempitem.misc9 = 0;
8778 285 tempitem.misc10 = 0;
8779 285 tempitem.wpn = 0;
8780 285 tempitem.wpn2 = 0;
8781 285 tempitem.wpn3 = 0;
8782 285 tempitem.wpn4 = 0;
8783 285 tempitem.wpn5 = 0;
8784 285 tempitem.wpn6 = 0;
8785 285 tempitem.wpn7 = 0;
8786 285 tempitem.wpn8 = 0;
8787 285 tempitem.wpn9 = 0;
8788 285 tempitem.wpn10 = 0;
8789 285 break;
8790 }
8791 case itype_crossscroll:
8792 {
8793 285 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8794 285 tempitem.misc1 = 0;
8795 285 tempitem.misc2 = 0;
8796 285 tempitem.misc3 = 0;
8797 285 tempitem.misc4 = 0;
8798 285 tempitem.misc5 = 0;
8799 285 tempitem.misc6 = 0;
8800 285 tempitem.misc7 = 0;
8801 285 tempitem.misc8 = 0;
8802 285 tempitem.misc9 = 0;
8803 285 tempitem.misc10 = 0;
8804 285 tempitem.wpn = 0;
8805 285 tempitem.wpn2 = 0;
8806 285 tempitem.wpn3 = 0;
8807 285 tempitem.wpn4 = 0;
8808 285 tempitem.wpn5 = 0;
8809 285 tempitem.wpn6 = 0;
8810 285 tempitem.wpn7 = 0;
8811 285 tempitem.wpn8 = 0;
8812 285 tempitem.wpn9 = 0;
8813 285 tempitem.wpn10 = 0;
8814 285 break;
8815 }
8816 case itype_quakescroll:
8817 {
8818 285 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8819 285 tempitem.misc3 = 0;
8820 285 tempitem.misc4 = 0;
8821 285 tempitem.misc5 = 0;
8822 285 tempitem.misc6 = 0;
8823 285 tempitem.misc7 = 0;
8824 285 tempitem.misc8 = 0;
8825 285 tempitem.misc9 = 0;
8826 285 tempitem.misc10 = 0;
8827 285 tempitem.wpn = 0;
8828 285 tempitem.wpn2 = 0;
8829 285 tempitem.wpn3 = 0;
8830 285 tempitem.wpn4 = 0;
8831 285 tempitem.wpn5 = 0;
8832 285 tempitem.wpn6 = 0;
8833 285 tempitem.wpn7 = 0;
8834 285 tempitem.wpn8 = 0;
8835 285 tempitem.wpn9 = 0;
8836 285 tempitem.wpn10 = 0;
8837 285 break;
8838 }
8839 case itype_whispring:
8840 {
8841 573 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8842 573 tempitem.misc2 = 0;
8843 573 tempitem.misc3 = 0;
8844 573 tempitem.misc4 = 0;
8845 573 tempitem.misc5 = 0;
8846 573 tempitem.misc6 = 0;
8847 573 tempitem.misc7 = 0;
8848 573 tempitem.misc8 = 0;
8849 573 tempitem.misc9 = 0;
8850 573 tempitem.misc10 = 0;
8851 573 tempitem.wpn = 0;
8852 573 tempitem.wpn2 = 0;
8853 573 tempitem.wpn3 = 0;
8854 573 tempitem.wpn4 = 0;
8855 573 tempitem.wpn5 = 0;
8856 573 tempitem.wpn6 = 0;
8857 573 tempitem.wpn7 = 0;
8858 573 tempitem.wpn8 = 0;
8859 573 tempitem.wpn9 = 0;
8860 573 tempitem.wpn10 = 0;
8861 573 break;
8862 }
8863 case itype_chargering:
8864 {
8865 570 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8866 570 tempitem.misc3 = 0;
8867 570 tempitem.misc4 = 0;
8868 570 tempitem.misc5 = 0;
8869 570 tempitem.misc6 = 0;
8870 570 tempitem.misc7 = 0;
8871 570 tempitem.misc8 = 0;
8872 570 tempitem.misc9 = 0;
8873 570 tempitem.misc10 = 0;
8874 570 tempitem.wpn = 0;
8875 570 tempitem.wpn2 = 0;
8876 570 tempitem.wpn3 = 0;
8877 570 tempitem.wpn4 = 0;
8878 570 tempitem.wpn5 = 0;
8879 570 tempitem.wpn6 = 0;
8880 570 tempitem.wpn7 = 0;
8881 570 tempitem.wpn8 = 0;
8882 570 tempitem.wpn9 = 0;
8883 570 tempitem.wpn10 = 0;
8884 570 break;
8885 }
8886 case itype_perilscroll:
8887 {
8888 285 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8889 285 tempitem.misc2 = 0;
8890 285 tempitem.misc3 = 0;
8891 285 tempitem.misc4 = 0;
8892 285 tempitem.misc5 = 0;
8893 285 tempitem.misc6 = 0;
8894 285 tempitem.misc7 = 0;
8895 285 tempitem.misc8 = 0;
8896 285 tempitem.misc9 = 0;
8897 285 tempitem.misc10 = 0;
8898 285 tempitem.wpn = 0;
8899 285 tempitem.wpn2 = 0;
8900 285 tempitem.wpn3 = 0;
8901 285 tempitem.wpn4 = 0;
8902 285 tempitem.wpn5 = 0;
8903 285 tempitem.wpn6 = 0;
8904 285 tempitem.wpn7 = 0;
8905 285 tempitem.wpn8 = 0;
8906 285 tempitem.wpn9 = 0;
8907 285 tempitem.wpn10 = 0;
8908 285 break;
8909 }
8910 case itype_wealthmedal:
8911 {
8912 858 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8913 858 tempitem.misc2 = 0;
8914 858 tempitem.misc3 = 0;
8915 858 tempitem.misc4 = 0;
8916 858 tempitem.misc5 = 0;
8917 858 tempitem.misc6 = 0;
8918 858 tempitem.misc7 = 0;
8919 858 tempitem.misc8 = 0;
8920 858 tempitem.misc9 = 0;
8921 858 tempitem.misc10 = 0;
8922 858 tempitem.wpn = 0;
8923 858 tempitem.wpn2 = 0;
8924 858 tempitem.wpn3 = 0;
8925 858 tempitem.wpn4 = 0;
8926 858 tempitem.wpn5 = 0;
8927 858 tempitem.wpn6 = 0;
8928 858 tempitem.wpn7 = 0;
8929 858 tempitem.wpn8 = 0;
8930 858 tempitem.wpn9 = 0;
8931 858 tempitem.wpn10 = 0;
8932 858 break;
8933 }
8934 case itype_heartring:
8935 {
8936 861 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8937 861 tempitem.misc3 = 0;
8938 861 tempitem.misc4 = 0;
8939 861 tempitem.misc5 = 0;
8940 861 tempitem.misc6 = 0;
8941 861 tempitem.misc7 = 0;
8942 861 tempitem.misc8 = 0;
8943 861 tempitem.misc9 = 0;
8944 861 tempitem.misc10 = 0;
8945 861 tempitem.wpn = 0;
8946 861 tempitem.wpn2 = 0;
8947 861 tempitem.wpn3 = 0;
8948 861 tempitem.wpn4 = 0;
8949 861 tempitem.wpn5 = 0;
8950 861 tempitem.wpn6 = 0;
8951 861 tempitem.wpn7 = 0;
8952 861 tempitem.wpn8 = 0;
8953 861 tempitem.wpn9 = 0;
8954 861 tempitem.wpn10 = 0;
8955 861 break;
8956 }
8957 case itype_magicring:
8958 {
8959 1152 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8960 1152 tempitem.misc3 = 0;
8961 1152 tempitem.misc4 = 0;
8962 1152 tempitem.misc5 = 0;
8963 1152 tempitem.misc6 = 0;
8964 1152 tempitem.misc7 = 0;
8965 1152 tempitem.misc8 = 0;
8966 1152 tempitem.misc9 = 0;
8967 1152 tempitem.misc10 = 0;
8968 1152 tempitem.wpn = 0;
8969 1152 tempitem.wpn2 = 0;
8970 1152 tempitem.wpn3 = 0;
8971 1152 tempitem.wpn4 = 0;
8972 1152 tempitem.wpn5 = 0;
8973 1152 tempitem.wpn6 = 0;
8974 1152 tempitem.wpn7 = 0;
8975 1152 tempitem.wpn8 = 0;
8976 1152 tempitem.wpn9 = 0;
8977 1152 tempitem.wpn10 = 0;
8978 1152 break;
8979 }
8980 case itype_spinscroll2:
8981 {
8982 285 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8983 285 tempitem.misc2 = 0;
8984 285 tempitem.misc3 = 0;
8985 285 tempitem.misc4 = 0;
8986 285 tempitem.misc5 = 0;
8987 285 tempitem.misc6 = 0;
8988 285 tempitem.misc7 = 0;
8989 285 tempitem.misc8 = 0;
8990 285 tempitem.misc9 = 0;
8991 285 tempitem.misc10 = 0;
8992 285 tempitem.wpn = 0;
8993 285 tempitem.wpn2 = 0;
8994 285 tempitem.wpn3 = 0;
8995 285 tempitem.wpn4 = 0;
8996 285 tempitem.wpn5 = 0;
8997 285 tempitem.wpn6 = 0;
8998 285 tempitem.wpn7 = 0;
8999 285 tempitem.wpn8 = 0;
9000 285 tempitem.wpn9 = 0;
9001 285 tempitem.wpn10 = 0;
9002 285 break;
9003 }
9004 case itype_quakescroll2:
9005 {
9006 285 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
9007 285 tempitem.misc3 = 0;
9008 285 tempitem.misc4 = 0;
9009 285 tempitem.misc5 = 0;
9010 285 tempitem.misc6 = 0;
9011 285 tempitem.misc7 = 0;
9012 285 tempitem.misc8 = 0;
9013 285 tempitem.misc9 = 0;
9014 285 tempitem.misc10 = 0;
9015 285 tempitem.wpn = 0;
9016 285 tempitem.wpn2 = 0;
9017 285 tempitem.wpn3 = 0;
9018 285 tempitem.wpn4 = 0;
9019 285 tempitem.wpn5 = 0;
9020 285 tempitem.wpn6 = 0;
9021 285 tempitem.wpn7 = 0;
9022 285 tempitem.wpn8 = 0;
9023 285 tempitem.wpn9 = 0;
9024 285 tempitem.wpn10 = 0;
9025 285 break;
9026 }
9027 case itype_agony:
9028 {
9029 285 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
9030 285 tempitem.misc2 = 0;
9031 285 tempitem.misc3 = 0;
9032 285 tempitem.misc4 = 0;
9033 285 tempitem.misc5 = 0;
9034 285 tempitem.misc6 = 0;
9035 285 tempitem.misc7 = 0;
9036 285 tempitem.misc8 = 0;
9037 285 tempitem.misc9 = 0;
9038 285 tempitem.misc10 = 0;
9039 285 tempitem.wpn = 0;
9040 285 tempitem.wpn2 = 0;
9041 285 tempitem.wpn3 = 0;
9042 285 tempitem.wpn4 = 0;
9043 285 tempitem.wpn5 = 0;
9044 285 tempitem.wpn6 = 0;
9045 285 tempitem.wpn7 = 0;
9046 285 tempitem.wpn8 = 0;
9047 285 tempitem.wpn9 = 0;
9048 285 tempitem.wpn10 = 0;
9049 285 break;
9050 }
9051 case itype_stompboots:
9052 {
9053 285 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
9054 285 tempitem.misc1 = 0;
9055 285 tempitem.misc2 = 0;
9056 285 tempitem.misc3 = 0;
9057 285 tempitem.misc4 = 0;
9058 285 tempitem.misc5 = 0;
9059 285 tempitem.misc6 = 0;
9060 285 tempitem.misc7 = 0;
9061 285 tempitem.misc8 = 0;
9062 285 tempitem.misc9 = 0;
9063 285 tempitem.misc10 = 0;
9064 285 tempitem.wpn = 0;
9065 285 tempitem.wpn2 = 0;
9066 285 tempitem.wpn3 = 0;
9067 285 tempitem.wpn4 = 0;
9068 285 tempitem.wpn5 = 0;
9069 285 tempitem.wpn6 = 0;
9070 285 tempitem.wpn7 = 0;
9071 285 tempitem.wpn8 = 0;
9072 285 tempitem.wpn9 = 0;
9073 285 tempitem.wpn10 = 0;
9074 285 break;
9075 }
9076 case itype_whimsicalring:
9077 {
9078 285 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
9079 285 tempitem.misc2 = 0;
9080 285 tempitem.misc3 = 0;
9081 285 tempitem.misc4 = 0;
9082 285 tempitem.misc5 = 0;
9083 285 tempitem.misc6 = 0;
9084 285 tempitem.misc7 = 0;
9085 285 tempitem.misc8 = 0;
9086 285 tempitem.misc9 = 0;
9087 285 tempitem.misc10 = 0;
9088 285 tempitem.wpn = 0;
9089 285 tempitem.wpn2 = 0;
9090 285 tempitem.wpn3 = 0;
9091 285 tempitem.wpn4 = 0;
9092 285 tempitem.wpn5 = 0;
9093 285 tempitem.wpn6 = 0;
9094 285 tempitem.wpn7 = 0;
9095 285 tempitem.wpn8 = 0;
9096 285 tempitem.wpn9 = 0;
9097 285 tempitem.wpn10 = 0;
9098 285 break;
9099 }
9100 case itype_perilring:
9101 {
9102 312 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
9103 312 tempitem.misc2 = 0;
9104 312 tempitem.misc3 = 0;
9105 312 tempitem.misc4 = 0;
9106 312 tempitem.misc5 = 0;
9107 312 tempitem.misc6 = 0;
9108 312 tempitem.misc7 = 0;
9109 312 tempitem.misc8 = 0;
9110 312 tempitem.misc9 = 0;
9111 312 tempitem.misc10 = 0;
9112 312 tempitem.wpn = 0;
9113 312 tempitem.wpn2 = 0;
9114 312 tempitem.wpn3 = 0;
9115 312 tempitem.wpn4 = 0;
9116 312 tempitem.wpn5 = 0;
9117 312 tempitem.wpn6 = 0;
9118 312 tempitem.wpn7 = 0;
9119 312 tempitem.wpn8 = 0;
9120 312 tempitem.wpn9 = 0;
9121 312 tempitem.wpn10 = 0;
9122 312 break;
9123 }
9124 case itype_custom1: case itype_custom2: case itype_custom3: case itype_custom4: case itype_custom5:
9125 case itype_custom6: case itype_custom7: case itype_custom8: case itype_custom9: case itype_custom10:
9126 case itype_custom11: case itype_custom12: case itype_custom13: case itype_custom14: case itype_custom15:
9127 case itype_custom16: case itype_custom17: case itype_custom18: case itype_custom19: case itype_custom20:
9128 case itype_bowandarrow: case itype_letterpotion: case itype_misc:
9129 {
9130 11134 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
9131 11134 tempitem.misc1 = 0;
9132 11134 tempitem.misc2 = 0;
9133 11134 tempitem.misc3 = 0;
9134 11134 tempitem.misc4 = 0;
9135 11134 tempitem.misc5 = 0;
9136 11134 tempitem.misc6 = 0;
9137 11134 tempitem.misc7 = 0;
9138 11134 tempitem.misc8 = 0;
9139 11134 tempitem.misc9 = 0;
9140 11134 tempitem.misc10 = 0;
9141 11134 tempitem.wpn = 0;
9142 11134 tempitem.wpn2 = 0;
9143 11134 tempitem.wpn3 = 0;
9144 11134 tempitem.wpn4 = 0;
9145 11134 tempitem.wpn5 = 0;
9146 11134 tempitem.wpn6 = 0;
9147 11134 tempitem.wpn7 = 0;
9148 11134 tempitem.wpn8 = 0;
9149 11134 tempitem.wpn9 = 0;
9150 11134 tempitem.wpn10 = 0;
9151 11134 break;
9152 }
9153 }
9154 73728 }
9155 //Port quest rules to items
9156
2/2
✓ Branch 0 taken 49152 times.
✓ Branch 1 taken 73728 times.
122880 if( s_version <= 31)
9157 {
9158
2/2
✓ Branch 0 taken 301 times.
✓ Branch 1 taken 73427 times.
73728 if(tempitem.family == itype_bomb)
9159 {
9160
2/2
✓ Branch 0 taken 156 times.
✓ Branch 1 taken 145 times.
301 if ( get_qr(qr_OUCHBOMBS) ) tempitem.flags |= item_flag2;
9161 145 else tempitem.flags &= ~ item_flag2;
9162 301 }
9163
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 73140 times.
73427 else if(tempitem.family == itype_sbomb)
9164 {
9165
2/2
✓ Branch 0 taken 158 times.
✓ Branch 1 taken 129 times.
287 if ( get_qr(qr_OUCHBOMBS) ) tempitem.flags |= item_flag2;
9166 129 else tempitem.flags &= ~ item_flag2;
9167 287 }
9168
9169
2/2
✓ Branch 0 taken 862 times.
✓ Branch 1 taken 72278 times.
73140 else if(tempitem.family == itype_brang)
9170 {
9171
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 862 times.
862 if ( get_qr(qr_BRANGPICKUP) ) tempitem.flags |= item_flag4;
9172 862 else tempitem.flags &= ~ item_flag4;
9173 862 }
9174
2/2
✓ Branch 0 taken 71975 times.
✓ Branch 1 taken 303 times.
72278 else if(tempitem.family == itype_wand)
9175 {
9176
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 279 times.
303 if ( get_qr(qr_NOWANDMELEE) ) tempitem.flags |= item_flag3;
9177 279 else tempitem.flags &= ~ item_flag3;
9178 303 }
9179 73728 }
9180
9181 //Port quest rules to items
9182
2/2
✓ Branch 0 taken 49152 times.
✓ Branch 1 taken 73728 times.
122880 if( s_version <= 37)
9183 {
9184
2/2
✓ Branch 0 taken 288 times.
✓ Branch 1 taken 73440 times.
73728 if(tempitem.family == itype_flippers)
9185 {
9186
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 209 times.
288 if ( (get_qr(qr_NODIVING)) ) tempitem.flags |= item_flag1;
9187 209 else tempitem.flags &= ~ item_flag1;
9188 288 }
9189
2/2
✓ Branch 0 taken 55748 times.
✓ Branch 1 taken 17692 times.
73440 else if(tempitem.family == itype_sword)
9190 {
9191
2/2
✓ Branch 0 taken 462 times.
✓ Branch 1 taken 17230 times.
17692 if ( (get_qr(qr_QUICKSWORD)) ) tempitem.flags |= item_flag5;
9192 17230 else tempitem.flags &= ~ item_flag5;
9193 17692 }
9194
2/2
✓ Branch 0 taken 303 times.
✓ Branch 1 taken 55445 times.
55748 else if(tempitem.family == itype_wand)
9195 {
9196
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 293 times.
303 if ( (get_qr(qr_QUICKSWORD)) ) tempitem.flags |= item_flag5;
9197 293 else tempitem.flags &= ~ item_flag5;
9198 303 }
9199
4/4
✓ Branch 0 taken 55144 times.
✓ Branch 1 taken 301 times.
✓ Branch 2 taken 612 times.
✓ Branch 3 taken 54532 times.
55445 else if(tempitem.family == itype_book || tempitem.family == itype_candle)
9200 {
9201 //@Emily: What was qrFIREPROOFHERO2 again, and does that also need to enable this?
9202
2/2
✓ Branch 0 taken 381 times.
✓ Branch 1 taken 532 times.
913 if ( (get_qr(qr_FIREPROOFHERO)) ) tempitem.flags |= item_flag3;
9203 532 else tempitem.flags &= ~ item_flag3;
9204 913 }
9205 73728 }
9206
9207
2/2
✓ Branch 0 taken 49152 times.
✓ Branch 1 taken 73728 times.
122880 if( s_version < 38)
9208 {
9209
4/4
✓ Branch 0 taken 72866 times.
✓ Branch 1 taken 862 times.
✓ Branch 2 taken 572 times.
✓ Branch 3 taken 72294 times.
73728 if(tempitem.family == itype_brang || tempitem.family == itype_hookshot)
9210 {
9211
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1434 times.
1434 if(get_qr(qr_BRANGPICKUP)) tempitem.flags |= item_flag4;
9212 1434 else tempitem.flags &= ~item_flag4;
9213
9214
2/2
✓ Branch 0 taken 703 times.
✓ Branch 1 taken 731 times.
1434 if(get_qr(qr_Z3BRANG_HSHOT)) tempitem.flags |= item_flag5 | item_flag6;
9215 731 else tempitem.flags &= ~(item_flag5|item_flag6);
9216 1434 }
9217
2/2
✓ Branch 0 taken 71447 times.
✓ Branch 1 taken 847 times.
72294 else if(tempitem.family == itype_arrow)
9218 {
9219
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 847 times.
847 if(get_qr(qr_BRANGPICKUP)) tempitem.flags |= item_flag4;
9220 847 else tempitem.flags &= ~item_flag4;
9221
9222
2/2
✓ Branch 0 taken 412 times.
✓ Branch 1 taken 435 times.
847 if(get_qr(qr_Z3BRANG_HSHOT)) tempitem.flags &= ~item_flag2;
9223 435 else tempitem.flags |= item_flag2;
9224 847 }
9225 73728 }
9226
9227
2/2
✓ Branch 0 taken 49152 times.
✓ Branch 1 taken 73728 times.
122880 if( s_version < 39)
9228 {
9229
6/6
✓ Branch 0 taken 73443 times.
✓ Branch 1 taken 285 times.
✓ Branch 2 taken 73142 times.
✓ Branch 3 taken 301 times.
✓ Branch 4 taken 612 times.
✓ Branch 5 taken 72530 times.
73728 if(tempitem.family == itype_divinefire || tempitem.family == itype_book || tempitem.family == itype_candle)
9230 {
9231
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 1182 times.
1198 if(get_qr(qr_TEMPCANDLELIGHT)) tempitem.flags |= item_flag5;
9232 1182 else tempitem.flags &= ~item_flag5;
9233 1198 }
9234
2/2
✓ Branch 0 taken 625 times.
✓ Branch 1 taken 71905 times.
72530 else if(tempitem.family == itype_potion)
9235 {
9236
2/2
✓ Branch 0 taken 162 times.
✓ Branch 1 taken 463 times.
625 if(get_qr(qr_NONBUBBLEMEDICINE))
9237 {
9238 162 tempitem.flags &= ~(item_flag3|item_flag4);
9239 162 }
9240 else
9241 {
9242 463 tempitem.flags |= item_flag3;
9243
2/2
✓ Branch 0 taken 130 times.
✓ Branch 1 taken 333 times.
463 if(get_qr(qr_ITEMBUBBLE))tempitem.flags |= item_flag4;
9244 333 else tempitem.flags &= ~item_flag4;
9245 }
9246 625 }
9247
2/2
✓ Branch 0 taken 71335 times.
✓ Branch 1 taken 570 times.
71905 else if(tempitem.family == itype_triforcepiece)
9248 {
9249
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 486 times.
570 if(get_qr(qr_NONBUBBLETRIFORCE))
9250 {
9251 84 tempitem.flags |= item_flag3;
9252
2/2
✓ Branch 0 taken 56 times.
✓ Branch 1 taken 28 times.
84 if(get_qr(qr_ITEMBUBBLE))tempitem.flags |= item_flag4;
9253 28 else tempitem.flags &= ~item_flag4;
9254 84 }
9255 else
9256 {
9257 486 tempitem.flags &= ~(item_flag3|item_flag4);
9258 }
9259 570 }
9260 73728 }
9261
9262
2/2
✓ Branch 0 taken 49152 times.
✓ Branch 1 taken 73728 times.
122880 if( s_version < 40)
9263 {
9264
4/4
✓ Branch 0 taken 72793 times.
✓ Branch 1 taken 935 times.
✓ Branch 2 taken 312 times.
✓ Branch 3 taken 72481 times.
73728 if(tempitem.family == itype_ring || tempitem.family == itype_perilring)
9265 {
9266
2/2
✓ Branch 0 taken 313 times.
✓ Branch 1 taken 934 times.
1247 if(get_qr(qr_RINGAFFECTDAMAGE))tempitem.flags |= item_flag1;
9267 934 else tempitem.flags &= ~item_flag1;
9268 1247 }
9269
8/8
✓ Branch 0 taken 71869 times.
✓ Branch 1 taken 612 times.
✓ Branch 2 taken 54177 times.
✓ Branch 3 taken 17692 times.
✓ Branch 4 taken 53874 times.
✓ Branch 5 taken 303 times.
✓ Branch 6 taken 285 times.
✓ Branch 7 taken 53589 times.
72481 else if(tempitem.family == itype_candle || tempitem.family == itype_sword || tempitem.family == itype_wand || tempitem.family == itype_cbyrna)
9270 {
9271
2/2
✓ Branch 0 taken 108 times.
✓ Branch 1 taken 18784 times.
18892 if(get_qr(qr_SLASHFLIPFIX))tempitem.flags |= item_flag8;
9272 18784 else tempitem.flags &= ~item_flag8;
9273 18892 }
9274
6/6
✓ Branch 0 taken 56036 times.
✓ Branch 1 taken 17692 times.
✓ Branch 2 taken 55733 times.
✓ Branch 3 taken 303 times.
✓ Branch 4 taken 288 times.
✓ Branch 5 taken 55445 times.
73728 if(tempitem.family == itype_sword || tempitem.family == itype_wand || tempitem.family == itype_hammer)
9275 {
9276
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 18179 times.
18283 if(get_qr(qr_NOITEMMELEE))tempitem.flags |= item_flag7;
9277 18179 else tempitem.flags &= ~item_flag7;
9278 18283 }
9279
2/2
✓ Branch 0 taken 55160 times.
✓ Branch 1 taken 285 times.
55445 else if(tempitem.family == itype_cbyrna)
9280 {
9281 285 tempitem.flags |= item_flag7;
9282 285 }
9283 73728 }
9284
9285
2/2
✓ Branch 0 taken 49152 times.
✓ Branch 1 taken 73728 times.
122880 if( s_version < 41 )
9286 {
9287
2/2
✓ Branch 0 taken 56036 times.
✓ Branch 1 taken 17692 times.
73728 if(tempitem.family == itype_sword)
9288 {
9289
2/2
✓ Branch 0 taken 284 times.
✓ Branch 1 taken 17408 times.
17692 if(get_qr(qr_SWORDMIRROR))tempitem.flags |= item_flag9;
9290 17408 else tempitem.flags &= ~item_flag9;
9291
9292
2/2
✓ Branch 0 taken 428 times.
✓ Branch 1 taken 17264 times.
17692 if(get_qr(qr_SLOWCHARGINGWALK))tempitem.flags |= item_flag10;
9293 17264 else tempitem.flags &= ~item_flag10;
9294 17692 }
9295 73728 }
9296
9297
2/2
✓ Branch 0 taken 49152 times.
✓ Branch 1 taken 73728 times.
122880 if( s_version < 42 )
9298 {
9299
2/2
✓ Branch 0 taken 303 times.
✓ Branch 1 taken 73425 times.
73728 if(tempitem.family == itype_wand)
9300 {
9301
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 279 times.
303 if(get_qr(qr_NOWANDMELEE))tempitem.flags |= item_flag3;
9302 279 else tempitem.flags &= ~item_flag3;
9303
9304 303 tempitem.flags &= ~item_flag6;
9305 303 }
9306
2/2
✓ Branch 0 taken 288 times.
✓ Branch 1 taken 73137 times.
73425 else if(tempitem.family == itype_hammer)
9307 {
9308 288 tempitem.flags &= ~item_flag3;
9309 288 }
9310
2/2
✓ Branch 0 taken 285 times.
✓ Branch 1 taken 72852 times.
73137 else if(tempitem.family == itype_cbyrna)
9311 {
9312 285 tempitem.flags |= item_flag3;
9313
9314 285 tempitem.flags &= ~item_flag6;
9315 285 }
9316
2/2
✓ Branch 0 taken 55160 times.
✓ Branch 1 taken 17692 times.
72852 else if(tempitem.family == itype_sword)
9317 {
9318
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17692 times.
17692 if(get_qr(qr_MELEEMAGICCOST))tempitem.flags |= item_flag6;
9319 17692 else tempitem.flags &= ~item_flag6;
9320 17692 }
9321 73728 }
9322
9323
2/2
✓ Branch 0 taken 49152 times.
✓ Branch 1 taken 73728 times.
122880 if( s_version < 43 )
9324 {
9325
2/2
✓ Branch 0 taken 73395 times.
✓ Branch 1 taken 333 times.
73728 if(tempitem.family == itype_whistle)
9326 {
9327
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 321 times.
333 if(get_qr(qr_WHIRLWINDMIRROR))tempitem.flags |= item_flag3;
9328 321 else tempitem.flags &= ~item_flag3;
9329 333 }
9330 73728 }
9331
9332
2/2
✓ Branch 0 taken 49152 times.
✓ Branch 1 taken 73728 times.
122880 if( s_version < 45 )
9333 {
9334
2/2
✓ Branch 0 taken 73440 times.
✓ Branch 1 taken 288 times.
73728 if(tempitem.family == itype_flippers)
9335 {
9336 288 tempitem.misc1 = 50; //Dive length, default 50 frames -V
9337 288 tempitem.misc2 = 30; //Dive cooldown, default 30 frames -V
9338 288 }
9339 73728 }
9340
9341
2/2
✓ Branch 0 taken 49152 times.
✓ Branch 1 taken 73728 times.
122880 if( s_version < 46 )
9342 {
9343
2/2
✓ Branch 0 taken 73443 times.
✓ Branch 1 taken 285 times.
73728 if(tempitem.family == itype_raft)
9344 {
9345 285 tempitem.misc1 = 1; //Rafting speed modifier; default 1. Negative slows, positive speeds.
9346 285 }
9347 73728 }
9348
2/2
✓ Branch 0 taken 49152 times.
✓ Branch 1 taken 73728 times.
122880 if ( s_version < 34 ) //! set the default counter for older quests.
9349 {
9350
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 73612 times.
73728 if ( (tempitem.flags & item_rupee_magic) )
9351 {
9352 116 tempitem.cost_counter[0] = 1;
9353 116 }
9354 else
9355 {
9356
2/2
✓ Branch 0 taken 44032 times.
✓ Branch 1 taken 29580 times.
73612 if(get_qr(qr_ENABLEMAGIC))
9357 44032 tempitem.cost_counter[0] = 4;
9358 else
9359 {
9360 29580 tempitem.cost_amount[0] = 0;
9361 29580 tempitem.cost_counter[0] = -1;
9362 }
9363 }
9364 73728 }
9365
9366
2/2
✓ Branch 0 taken 49152 times.
✓ Branch 1 taken 73728 times.
122880 if ( s_version < 35 ) //new Lens of Truth flags
9367 {
9368
2/2
✓ Branch 0 taken 73467 times.
✓ Branch 1 taken 261 times.
73728 if ( tempitem.family == itype_lens )
9369 {
9370
2/2
✓ Branch 0 taken 249 times.
✓ Branch 1 taken 12 times.
261 if ( get_qr(qr_RAFTLENS) )
9371 {
9372 12 tempitem.flags |= item_flag4;
9373 12 }
9374
2/2
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 167 times.
261 if ( get_qr(qr_LENSHINTS) )
9375 {
9376 167 tempitem.flags |= item_flag1;
9377 167 }
9378
2/2
✓ Branch 0 taken 245 times.
✓ Branch 1 taken 16 times.
261 if ( get_qr(qr_LENSSEESENEMIES) )
9379 {
9380 16 tempitem.flags |= item_flag5;
9381 16 }
9382 261 }
9383 73728 }
9384
2/2
✓ Branch 0 taken 49152 times.
✓ Branch 1 taken 73728 times.
122880 if ( s_version < 44 ) //InitD Labels and Sprite Script Data
9385 {
9386
2/2
✓ Branch 0 taken 589824 times.
✓ Branch 1 taken 73728 times.
663552 for ( int32_t q = 0; q < 8; q++ )
9387 {
9388 589824 sprintf(tempitem.initD_label[q],"InitD[%d]",q);
9389 589824 sprintf(tempitem.sprite_initD_label[q],"InitD[%d]",q);
9390 589824 tempitem.sprite_initiald[q] = 0;
9391 589824 }
9392 73728 tempitem.sprite_script = 0;
9393 73728 }
9394
2/2
✓ Branch 0 taken 49152 times.
✓ Branch 1 taken 73728 times.
122880 if ( s_version < 47 ) //InitD Labels and Sprite Script Data
9395 {
9396 73728 tempitem.pickupflag = 0;
9397 73728 }
9398
9399
2/2
✓ Branch 0 taken 49152 times.
✓ Branch 1 taken 73728 times.
122880 if( s_version < 51 )
9400 {
9401
2/2
✓ Branch 0 taken 73116 times.
✓ Branch 1 taken 612 times.
73728 if( tempitem.family == itype_candle )
9402 {
9403 612 tempitem.misc4 = 50; //Step speed
9404 612 }
9405 73728 }
9406
9407
2/2
✓ Branch 0 taken 49152 times.
✓ Branch 1 taken 73728 times.
122880 if( s_version < 52 )
9408 {
9409
2/2
✓ Branch 0 taken 72852 times.
✓ Branch 1 taken 876 times.
73728 if( tempitem.family == itype_shield )
9410 876 tempitem.flags |= item_flag1; //'Block Front' flag
9411 73728 }
9412
2/2
✓ Branch 0 taken 49152 times.
✓ Branch 1 taken 73728 times.
122880 if(s_version < 53)
9413 {
9414
4/4
✓ Branch 0 taken 301 times.
✓ Branch 1 taken 72293 times.
✓ Branch 2 taken 847 times.
✓ Branch 3 taken 287 times.
73728 switch(tempitem.family)
9415 {
9416 case itype_arrow:
9417 847 tempitem.cost_counter[1] = crARROWS;
9418 847 tempitem.cost_amount[1] = 1;
9419 847 break;
9420 case itype_bomb:
9421 301 tempitem.cost_counter[1] = crBOMBS;
9422 301 tempitem.cost_amount[1] = 1;
9423 301 break;
9424 case itype_sbomb:
9425 287 tempitem.cost_counter[1] = crSBOMBS;
9426 287 tempitem.cost_amount[1] = 1;
9427 287 break;
9428 default:
9429 72293 tempitem.cost_counter[1] = crNONE;
9430 72293 tempitem.cost_amount[1] = 0;
9431 72293 }
9432 73728 tempitem.magiccosttimer[1] = 0;
9433 73728 }
9434
2/2
✓ Branch 0 taken 46336 times.
✓ Branch 1 taken 76544 times.
122880 if( s_version < 54 )
9435 {
9436
2/2
✓ Branch 0 taken 76243 times.
✓ Branch 1 taken 301 times.
76544 if( tempitem.family == itype_flippers )
9437 301 tempitem.misc3 = INT_BTN_A; //'Block Front' flag
9438 76544 }
9439
2/2
✓ Branch 0 taken 46336 times.
✓ Branch 1 taken 76544 times.
122880 if(s_version < 55)
9440 {
9441
3/3
✓ Branch 0 taken 592 times.
✓ Branch 1 taken 592 times.
✓ Branch 2 taken 75360 times.
76544 switch(tempitem.family)
9442 {
9443 case itype_spinscroll:
9444 case itype_quakescroll:
9445 592 tempitem.usesound2 = WAV_ZN1CHARGE;
9446 592 break;
9447 case itype_spinscroll2:
9448 case itype_quakescroll2:
9449 592 tempitem.usesound2 = WAV_ZN1CHARGE2;
9450 592 break;
9451 }
9452 76544 }
9453
2/2
✓ Branch 0 taken 46336 times.
✓ Branch 1 taken 76544 times.
122880 if(s_version < 56)
9454 {
9455
4/4
✓ Branch 0 taken 75298 times.
✓ Branch 1 taken 296 times.
✓ Branch 2 taken 638 times.
✓ Branch 3 taken 312 times.
76544 switch(tempitem.family)
9456 {
9457 case itype_divinefire:
9458
2/2
✓ Branch 0 taken 285 times.
✓ Branch 1 taken 11 times.
296 SETFLAG(tempitem.flags, item_flag9, version < 0x255); //Strong Fire
9459
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 214 times.
296 SETFLAG(tempitem.flags, item_flag10, version < 0x250); //Magic Fire
9460 296 tempitem.flags |= item_flag11; //Divine Fire
9461 296 break;
9462 case itype_candle:
9463
2/2
✓ Branch 0 taken 318 times.
✓ Branch 1 taken 320 times.
638 SETFLAG(tempitem.flags, item_flag9, tempitem.fam_type > 1); //Strong Fire
9464 638 tempitem.flags &= ~item_flag10; //Magic Fire
9465 638 tempitem.flags &= ~item_flag11; //Divine Fire
9466 638 break;
9467 case itype_book:
9468 312 tempitem.flags |= item_flag9; //Strong Fire
9469 312 tempitem.flags |= item_flag10; //Magic Fire
9470 312 tempitem.flags &= ~item_flag11; //Divine Fire
9471 312 break;
9472 }
9473 76544 }
9474
2/2
✓ Branch 0 taken 32768 times.
✓ Branch 1 taken 90112 times.
122880 if (s_version < 61)
9475 {
9476
2/2
✓ Branch 0 taken 71153 times.
✓ Branch 1 taken 18959 times.
90112 switch (tempitem.family)
9477 {
9478 case itype_sword:
9479 18959 tempitem.usesound2 = WAV_BEAM;
9480 18959 break;
9481 }
9482 90112 }
9483
9484
9485
2/2
✓ Branch 0 taken 111892 times.
✓ Branch 1 taken 10988 times.
122880 if(tempitem.fam_type==0) // Always do this
9486 10988 tempitem.fam_type=1;
9487
9488 122880 itemsbuf[i] = tempitem;
9489 122880 }
9490
9491 480 return 0;
9492 481 }
9493
9494 static bool did_init_def_items = false;
9495 245626 void init_def_items()
9496 {
9497
2/2
✓ Branch 0 taken 245255 times.
✓ Branch 1 taken 371 times.
245626 if(did_init_def_items) return;
9498 371 did_init_def_items = true;
9499 371 default_items[3].cost_counter[1] = crBOMBS;
9500 371 default_items[13].cost_counter[1] = crARROWS;
9501 371 default_items[14].cost_counter[1] = crARROWS;
9502 371 default_items[48].cost_counter[1] = crSBOMBS;
9503 371 default_items[57].cost_counter[1] = crARROWS;
9504 245626 }
9505 245626 void reset_itembuf(itemdata *item, int32_t id)
9506 {
9507 245626 init_def_items();
9508
2/2
✓ Branch 0 taken 103169 times.
✓ Branch 1 taken 142457 times.
245626 if(id<iLast)
9509 {
9510 // Copy everything *EXCEPT* the tile, misc, cset, frames, speed, delay and ltm.
9511 142457 word tile = item->tile;
9512 142457 byte miscs = item->misc_flags, cset = item->csets, frames = item->frames, speed = item->speed, delay = item->delay;
9513 142457 int32_t ltm = item->ltm;
9514
9515 142457 *item = default_items[id];
9516 142457 item->tile = tile;
9517 142457 item->misc_flags = miscs;
9518 142457 item->csets = cset;
9519 142457 item->frames = frames;
9520 142457 item->speed = speed;
9521 142457 item->delay = delay;
9522 142457 item->ltm = ltm;
9523 142457 }
9524 245626 }
9525
9526 101632 void reset_itemname(int32_t id)
9527 {
9528 101632 sprintf(item_string[id],"zz%03d",id);
9529
9530
2/2
✓ Branch 0 taken 44861 times.
✓ Branch 1 taken 56771 times.
101632 if(id < iLast)
9531 56771 strcpy(item_string[id],old_item_string[id]);
9532 101632 }
9533
9534 481 int32_t readweapons(PACKFILE *f, zquestheader *Header)
9535 {
9536
2/2
✓ Branch 0 taken 457 times.
✓ Branch 1 taken 24 times.
481 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_weapons);
9537
9538 481 word weapons_to_read=MAXWPNS;
9539 int32_t dummy;
9540 byte padding;
9541 wpndata tempweapon;
9542 481 word s_version=0;
9543
9544
9545
2/2
✓ Branch 0 taken 475 times.
✓ Branch 1 taken 6 times.
481 if(Header->zelda_version < 0x186)
9546 {
9547 6 weapons_to_read=64;
9548 6 }
9549
9550
2/2
✓ Branch 0 taken 475 times.
✓ Branch 1 taken 6 times.
481 if(Header->zelda_version < 0x185)
9551 {
9552 6 weapons_to_read=32;
9553 6 }
9554
9555
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 457 times.
481 if(Header->zelda_version > 0x192)
9556 {
9557 457 weapons_to_read=0;
9558
9559 //section version info
9560
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 if(!p_igetw(&s_version,f))
9561 {
9562 return qe_invalid;
9563 }
9564
9565 457 FFCore.quest_format[vWeaponSprites] = s_version;
9566
9567
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 if(!read_deprecated_section_cversion(f))
9568 {
9569 return qe_invalid;
9570 }
9571
9572 //section size
9573
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 if(!p_igetl(&dummy,f))
9574 {
9575 return qe_invalid;
9576 }
9577
9578 //finally... section data
9579
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 if(!p_igetw(&weapons_to_read,f))
9580 {
9581 return qe_invalid;
9582 }
9583
9584
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
457 if (weapons_to_read > MAXWPNS)
9585 {
9586 return qe_invalid;
9587 }
9588 457 }
9589
9590
2/2
✓ Branch 0 taken 398 times.
✓ Branch 1 taken 83 times.
481 if(s_version>2)
9591 {
9592
2/2
✓ Branch 0 taken 101888 times.
✓ Branch 1 taken 398 times.
102286 for(int32_t i=0; i<weapons_to_read; i++)
9593 {
9594 char tempname[64];
9595
9596
1/2
✓ Branch 0 taken 101888 times.
✗ Branch 1 not taken.
101888 if(!pfread(tempname, 64, f))
9597 {
9598 return qe_invalid;
9599 }
9600
9601 101888 weapon_string[i][0] = '\0';
9602 101888 strncat(weapon_string[i], tempname, 64 - 1);
9603 101888 }
9604
9605
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(s_version<4)
9606 {
9607 strcpy(weapon_string[iwHover],old_weapon_string[iwHover]);
9608 strcpy(weapon_string[wFIREMAGIC],old_weapon_string[wFIREMAGIC]);
9609 }
9610
9611
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(s_version<5)
9612 {
9613 strcpy(weapon_string[iwQuarterHearts],old_weapon_string[iwQuarterHearts]);
9614 }
9615
9616 /*
9617 if (s_version<6)
9618 {
9619 strcpy(weapon_string[iwSideRaft],old_weapon_string[iwSideRaft]);
9620 strcpy(weapon_string[iwSideLadder],old_weapon_string[iwSideLadder]);
9621 }
9622 */
9623 398 }
9624
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 82 times.
83 else if (!should_skip)
9625 {
9626
2/2
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 82 times.
21074 for(int32_t i=0; i<MAXWPNS; i++)
9627 20992 reset_weaponname(i);
9628 82 }
9629
9630
2/2
✓ Branch 0 taken 110700 times.
✓ Branch 1 taken 481 times.
111181 for(int32_t i=0; i<weapons_to_read; i++)
9631 {
9632 110700 word oldtile = 0;
9633
2/2
✓ Branch 0 taken 47872 times.
✓ Branch 1 taken 62828 times.
110700 if (s_version < 8)
9634 {
9635
1/2
✓ Branch 0 taken 62828 times.
✗ Branch 1 not taken.
62828 if (!p_igetw(&oldtile, f))
9636 return qe_invalid;
9637 62828 }
9638
9639
1/2
✓ Branch 0 taken 110700 times.
✗ Branch 1 not taken.
110700 if(!p_getc(&tempweapon.misc,f))
9640 {
9641 return qe_invalid;
9642 }
9643
9644
1/2
✓ Branch 0 taken 110700 times.
✗ Branch 1 not taken.
110700 if(!p_getc(&tempweapon.csets,f))
9645 {
9646 return qe_invalid;
9647 }
9648
9649
1/2
✓ Branch 0 taken 110700 times.
✗ Branch 1 not taken.
110700 if(!p_getc(&tempweapon.frames,f))
9650 {
9651 return qe_invalid;
9652 }
9653
9654
1/2
✓ Branch 0 taken 110700 times.
✗ Branch 1 not taken.
110700 if(!p_getc(&tempweapon.speed,f))
9655 {
9656 return qe_invalid;
9657 }
9658
9659
1/2
✓ Branch 0 taken 110700 times.
✗ Branch 1 not taken.
110700 if(!p_getc(&tempweapon.type,f))
9660 {
9661 return qe_invalid;
9662 }
9663
9664
2/2
✓ Branch 0 taken 61548 times.
✓ Branch 1 taken 49152 times.
110700 if ( s_version >= 7 )
9665 {
9666
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetw(&tempweapon.script,f))
9667 {
9668 return qe_invalid;
9669 }
9670
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetl(&tempweapon.tile,f))
9671 {
9672 return qe_invalid;
9673 }
9674 49152 }
9675
2/2
✓ Branch 0 taken 49152 times.
✓ Branch 1 taken 61548 times.
110700 if ( s_version < 7 )
9676 {
9677 61548 tempweapon.tile = oldtile;
9678 61548 }
9679
9680
2/2
✓ Branch 0 taken 105900 times.
✓ Branch 1 taken 4800 times.
110700 if(Header->zelda_version < 0x193)
9681 {
9682
1/2
✓ Branch 0 taken 4800 times.
✗ Branch 1 not taken.
4800 if(!p_getc(&padding,f))
9683 {
9684 return qe_invalid;
9685 }
9686 4800 }
9687
9688
2/2
✓ Branch 0 taken 101888 times.
✓ Branch 1 taken 8812 times.
110700 if(s_version < 6)
9689 {
9690
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 8794 times.
8812 if(i==ewFIRETRAIL)
9691 {
9692 18 tempweapon.misc |= WF_BEHIND;
9693 18 }
9694 else
9695 8794 tempweapon.misc &= ~WF_BEHIND;
9696 8812 }
9697
9698
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 110444 times.
110700 if (!should_skip)
9699 110444 memcpy(&wpnsbuf[i], &tempweapon, sizeof(tempweapon));
9700 110700 }
9701
9702
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 480 times.
481 if (should_skip)
9703 1 return 0;
9704
9705
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 398 times.
480 if(s_version<2)
9706 {
9707 82 wpnsbuf[wSBOOM]=wpnsbuf[wBOOM];
9708 82 }
9709
9710
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 398 times.
480 if(s_version<5)
9711 {
9712 82 wpnsbuf[iwQuarterHearts].tile=1;
9713 82 wpnsbuf[iwQuarterHearts].csets=1;
9714 82 }
9715
9716
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 480 times.
480 if(Header->zelda_version < 0x176)
9717 {
9718 wpnsbuf[iwSpawn] = *((wpndata*)(itemsbuf + iMisc1));
9719 wpnsbuf[iwDeath] = *((wpndata*)(itemsbuf + iMisc2));
9720 itemsbuf[iMisc1].clear();
9721 itemsbuf[iMisc2].clear();
9722 }
9723
9724
3/4
✓ Branch 0 taken 462 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
485 if((Header->zelda_version < 0x192)||
9725
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 457 times.
462 ((Header->zelda_version == 0x192)&&(Header->build<129)))
9726 {
9727 18 wpnsbuf[wHSCHAIN_V] = wpnsbuf[wHSCHAIN_H];
9728 18 }
9729
9730
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 457 times.
480 if((Header->zelda_version < 0x210))
9731 {
9732 23 wpnsbuf[wLSHEAD] = wpnsbuf[wHSHEAD];
9733 23 wpnsbuf[wLSCHAIN_H] = wpnsbuf[wHSCHAIN_H];
9734 23 wpnsbuf[wLSHANDLE] = wpnsbuf[wHSHANDLE];
9735 23 wpnsbuf[wLSCHAIN_V] = wpnsbuf[wHSCHAIN_V];
9736 23 }
9737
9738 480 return 0;
9739 481 }
9740
9741 224348 static void guy_update_firesfx(guydata& tempguy)
9742 {
9743 224348 tempguy.firesfx = 0;
9744
2/2
✓ Branch 0 taken 6463 times.
✓ Branch 1 taken 217885 times.
224348 if (tempguy.family == eeWIZZ)
9745 {
9746
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 977 times.
✓ Branch 2 taken 3950 times.
✓ Branch 3 taken 832 times.
✓ Branch 4 taken 704 times.
6463 switch (tempguy.attributes[1])
9747 {
9748 case 0: // normal weapon
9749 3950 tempguy.firesfx = WAV_WAND;
9750 3950 break;
9751 case 1: // 8 shots
9752
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 750 times.
832 if (get_qr(qr_8WAY_SHOT_SFX_DEP)) tempguy.firesfx = WAV_FIRE;
9753 else
9754 {
9755
3/8
✓ Branch 0 taken 646 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 88 times.
✓ Branch 3 taken 16 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
750 switch (tempguy.weapon)
9756 {
9757 case ewFireTrail:
9758 case ewFlame:
9759 case ewFlame2Trail:
9760 case ewFlame2:
9761 646 tempguy.firesfx = WAV_FIRE;
9762 646 break;
9763 case ewWind:
9764 case ewMagic:
9765 88 tempguy.firesfx = WAV_WAND;
9766 88 break;
9767 case ewIce:
9768 tempguy.firesfx = WAV_ZN1ICE;
9769 break;
9770 case ewRock:
9771 tempguy.firesfx = WAV_ZN1ROCK;
9772 break;
9773 case ewFireball2:
9774 case ewFireball:
9775 16 tempguy.firesfx = WAV_ZN1FIREBALL;
9776 16 break;
9777 case ewBrang:
9778 tempguy.firesfx = WAV_BRANG;
9779 break;
9780 case ewBomb:case ewSBomb: case ewLitBomb:case ewLitSBomb:
9781 tempguy.firesfx = WAV_BOMB;
9782 break;
9783 default:
9784 tempguy.firesfx = 0;
9785 break;
9786 }
9787 750 break;
9788 }
9789 case 2: // Summon
9790 1059 tempguy.firesfx = WAV_FIRE;
9791 1059 break;
9792 case 3: // Summon Layer
9793 704 tempguy.firesfx = get_qr(qr_MORESOUNDS) ? WAV_ZN1SUMMON : WAV_FIRE;
9794 704 break;
9795 }
9796 6463 }
9797 else
9798 {
9799
6/6
✓ Branch 0 taken 164878 times.
✓ Branch 1 taken 53007 times.
✓ Branch 2 taken 42127 times.
✓ Branch 3 taken 207005 times.
✓ Branch 4 taken 47569 times.
✓ Branch 5 taken 47565 times.
217885 if ((tempguy.family == eeWALK || tempguy.family == eePROJECTILE) && (tempguy.attributes[0] == e1tSUMMON || tempguy.attributes[0] == e1tSUMMONLAYER))
9800 {
9801 95134 tempguy.firesfx = get_qr(qr_MORESOUNDS) ? WAV_ZN1SUMMON : WAV_FIRE;
9802 95134 }
9803 else
9804 {
9805
7/8
✓ Branch 0 taken 9670 times.
✓ Branch 1 taken 2369 times.
✓ Branch 2 taken 1814 times.
✓ Branch 3 taken 12891 times.
✓ Branch 4 taken 174000 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3981 times.
✓ Branch 7 taken 2280 times.
207005 switch (tempguy.weapon)
9806 {
9807 case ewFireTrail:
9808 case ewFlame:
9809 case ewFlame2Trail:
9810 case ewFlame2:
9811 9670 tempguy.firesfx = WAV_FIRE;
9812 9670 break;
9813 case ewWind:
9814 case ewMagic:
9815 1814 tempguy.firesfx = WAV_WAND;
9816 1814 break;
9817 case ewIce:
9818 tempguy.firesfx = WAV_ZN1ICE;
9819 break;
9820 case ewRock:
9821 3981 tempguy.firesfx = WAV_ZN1ROCK;
9822 3981 break;
9823 case ewFireball2:
9824 case ewFireball:
9825 12891 tempguy.firesfx = WAV_ZN1FIREBALL;
9826 12891 break;
9827 case ewBrang:
9828 2280 tempguy.firesfx = WAV_BRANG;
9829 2280 break;
9830 case ewBomb:case ewSBomb: case ewLitBomb:case ewLitSBomb:
9831 2369 tempguy.firesfx = WAV_BOMB;
9832 2369 break;
9833 default:
9834 174000 tempguy.firesfx = 0;
9835 174000 break;
9836 }
9837 }
9838 }
9839 213472 }
9840
9841 213472 static void guy_update_weaponflags(guydata& tempguy)
9842 {
9843 213472 tempguy.weap_data.unblockable = 0;
9844 213472 tempguy.weap_data.moveflags = move_none;
9845
4/4
✓ Branch 0 taken 206909 times.
✓ Branch 1 taken 6563 times.
✓ Branch 2 taken 3018 times.
✓ Branch 3 taken 203891 times.
213472 if (tempguy.weapon == ewFlame || tempguy.weapon == ewFireTrail)
9846 9581 tempguy.weap_data.moveflags |= (move_obeys_grav | move_can_pitfall);
9847 213472 tempguy.weap_data.override_flags = 0;
9848 213472 tempguy.weap_data.hxofs = 0;
9849 213472 tempguy.weap_data.hyofs = 0;
9850 213472 tempguy.weap_data.hxsz = 0;
9851 213472 tempguy.weap_data.hysz = 0;
9852 213472 tempguy.weap_data.hzsz = 0;
9853 213472 tempguy.weap_data.xofs = 0;
9854 213472 tempguy.weap_data.yofs = 0;
9855 213472 tempguy.weap_data.tilew = 0;
9856 213472 tempguy.weap_data.tileh = 0;
9857
5/5
✓ Branch 0 taken 2519 times.
✓ Branch 1 taken 172014 times.
✓ Branch 2 taken 18609 times.
✓ Branch 3 taken 12907 times.
✓ Branch 4 taken 7423 times.
213472 switch (tempguy.weapon)
9858 {
9859 case ewFireball: case ewFireball2:
9860 12907 tempguy.weap_data.step = 1.75_zf;
9861 12907 break;
9862 case ewSword: case ewLitBomb: case ewLitSBomb:
9863 case ewRock: case ewMagic: case ewWind:
9864 18609 tempguy.weap_data.step = 3_zf;
9865 18609 break;
9866 case ewArrow:
9867 2519 tempguy.weap_data.step = 2_zf;
9868 2519 break;
9869 case ewFlame: case ewFlame2:
9870 7423 tempguy.weap_data.step = 1_zf;
9871 7423 break;
9872 default:
9873 172014 tempguy.weap_data.step = 0_zf;
9874 172014 break;
9875 }
9876
2/2
✓ Branch 0 taken 1067360 times.
✓ Branch 1 taken 213472 times.
1280832 for (int q = 0; q < WPNSPR_MAX; ++q)
9877 {
9878 1067360 tempguy.weap_data.burnsprs[q] = 0;
9879 1067360 tempguy.weap_data.light_rads[q] = 0;
9880 1067360 }
9881 213472 }
9882
9883 213472 static void guy_update_weaponspecialsfx(guydata& tempguy)
9884 {
9885
3/3
✓ Branch 0 taken 2280 times.
✓ Branch 1 taken 208768 times.
✓ Branch 2 taken 2424 times.
213472 switch (tempguy.weapon)
9886 {
9887 case ewBrang:
9888 2280 tempguy.specialsfx = WAV_BRANG;
9889 2280 break;
9890 case ewBomb: case ewSBomb: case ewLitBomb:case ewLitSBomb:
9891 2424 tempguy.specialsfx = WAV_BOMB;
9892 2424 break;
9893 default:
9894 208768 tempguy.specialsfx = 0;
9895 208768 break;
9896 }
9897 213472 }
9898
9899 480 void init_guys(int32_t guyversion)
9900 {
9901
2/2
✓ Branch 0 taken 245760 times.
✓ Branch 1 taken 480 times.
246240 for(int32_t i=0; i<MAXGUYS; i++)
9902 {
9903 245760 guysbuf[i] = default_guys[0];
9904 245760 }
9905
9906
2/2
✓ Branch 0 taken 84960 times.
✓ Branch 1 taken 480 times.
85440 for(int32_t i=0; i<OLDMAXGUYS; i++)
9907 {
9908 84960 guysbuf[i] = default_guys[i];
9909
2/2
✓ Branch 0 taken 84000 times.
✓ Branch 1 taken 960 times.
84960 guysbuf[i].spr_shadow = (guysbuf[i].family==eeROCK && guysbuf[i].attributes[9] == 1) ? iwLargeShadow : iwShadow;
9910 84960 guysbuf[i].spr_death = iwDeath;
9911 84960 guysbuf[i].spr_spawn = iwSpawn;
9912 // Patra fix: 2.10 BSPatras used spDIG. 2.50 Patras use CSet 7.
9913
4/4
✓ Branch 0 taken 14514 times.
✓ Branch 1 taken 70446 times.
✓ Branch 2 taken 14432 times.
✓ Branch 3 taken 82 times.
84960 if(guyversion<=3 && i==ePATRABS)
9914 {
9915 82 guysbuf[i].bosspal=spDIG;
9916 82 guysbuf[i].cset=14;
9917 82 guysbuf[i].attributes[8] = 14;
9918 82 }
9919
9920
2/2
✓ Branch 0 taken 70446 times.
✓ Branch 1 taken 14514 times.
84960 if(guyversion<=3)
9921 {
9922 // Rope/Ghini Flash rules
9923
2/2
✓ Branch 0 taken 4071 times.
✓ Branch 1 taken 10443 times.
14514 if(get_bit(deprecated_rules, qr_NOROPE2FLASH_DEP))
9924 {
9925
2/2
✓ Branch 0 taken 10384 times.
✓ Branch 1 taken 59 times.
10443 if(i==eROPE2)
9926 {
9927 59 guysbuf[i].flags &= ~guy_flashing;
9928 59 }
9929 10443 }
9930
9931
2/2
✓ Branch 0 taken 12390 times.
✓ Branch 1 taken 2124 times.
14514 if(get_bit(deprecated_rules, qr_NOBUBBLEFLASH_DEP))
9932 {
9933
12/12
✓ Branch 0 taken 2112 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 2100 times.
✓ Branch 3 taken 12 times.
✓ Branch 4 taken 2088 times.
✓ Branch 5 taken 12 times.
✓ Branch 6 taken 2076 times.
✓ Branch 7 taken 12 times.
✓ Branch 8 taken 2064 times.
✓ Branch 9 taken 12 times.
✓ Branch 10 taken 12 times.
✓ Branch 11 taken 2052 times.
2124 if(i==eBUBBLEST || i==eBUBBLESP || i==eBUBBLESR || i==eBUBBLEIT || i==eBUBBLEIP || i==eBUBBLEIR)
9934 {
9935 72 guysbuf[i].flags &= ~guy_flashing;
9936 72 }
9937 2124 }
9938
9939
2/2
✓ Branch 0 taken 14432 times.
✓ Branch 1 taken 82 times.
14514 if(i==eGHINI2)
9940 {
9941
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 4 times.
82 if(get_bit(deprecated_rules, qr_GHINI2BLINK_DEP))
9942 {
9943 4 guysbuf[i].flags |= guy_blinking;
9944 4 }
9945
9946
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 38 times.
82 if(get_bit(deprecated_rules, qr_PHANTOMGHINI2_DEP))
9947 {
9948 38 guysbuf[i].flags |= guy_transparent;
9949 38 }
9950 82 }
9951
9952
4/4
✓ Branch 0 taken 14432 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 14350 times.
14514 if (i == eDIG1 || i == eDIG3)
9953 {
9954 164 guysbuf[i].flags |= guy_ignore_kill_all;
9955 164 }
9956 14514 }
9957
9958 // Darknut fix
9959
10/10
✓ Branch 0 taken 84480 times.
✓ Branch 1 taken 480 times.
✓ Branch 2 taken 84000 times.
✓ Branch 3 taken 480 times.
✓ Branch 4 taken 83520 times.
✓ Branch 5 taken 480 times.
✓ Branch 6 taken 83040 times.
✓ Branch 7 taken 480 times.
✓ Branch 8 taken 480 times.
✓ Branch 9 taken 82560 times.
84960 if(i==eDKNUT1 || i==eDKNUT2 || i==eDKNUT3 || i==eDKNUT4 || i==eDKNUT5)
9960 {
9961
2/2
✓ Branch 0 taken 1990 times.
✓ Branch 1 taken 410 times.
2400 if(get_qr(qr_NEWENEMYTILES))
9962 {
9963 1990 guysbuf[i].s_tile=guysbuf[i].e_tile+120;
9964 1990 guysbuf[i].s_width=guysbuf[i].e_width;
9965 1990 guysbuf[i].s_height=guysbuf[i].e_height;
9966 1990 }
9967 410 else guysbuf[i].s_tile=860;
9968
9969
2/2
✓ Branch 0 taken 320 times.
✓ Branch 1 taken 2080 times.
2400 if(!get_bit(deprecated_rules,qr_BRKBLSHLDS_DEP))
9970 2080 guysbuf[i].flags &= ~guy_bkshield;
9971 else
9972 320 guysbuf[i].flags |= guy_bkshield;
9973 2400 }
9974
9975
4/4
✓ Branch 0 taken 84480 times.
✓ Branch 1 taken 480 times.
✓ Branch 2 taken 84910 times.
✓ Branch 3 taken 50 times.
84960 if((i==eGELTRIB || i==eFGELTRIB) && get_bit(deprecated_rules,qr_OLDTRIBBLES_DEP))
9976 {
9977 50 guysbuf[i].attributes[2] = (i == eFGELTRIB ? eFZOL : eZOL);
9978 50 }
9979
9980 84960 guy_update_firesfx(guysbuf[i]);
9981 84960 guy_update_weaponflags(guysbuf[i]);
9982 84960 guy_update_weaponspecialsfx(guysbuf[i]);
9983 84960 }
9984 480 }
9985
9986 20992 void reset_weaponname(int32_t i)
9987 {
9988
2/2
✓ Branch 0 taken 7216 times.
✓ Branch 1 taken 13776 times.
20992 if(i<wLast)
9989 {
9990 7216 strcpy(weapon_string[i],old_weapon_string[i]);
9991 7216 }
9992 else
9993 13776 sprintf(weapon_string[i],"zz%03d",i);
9994 20992 }
9995
9996 480 void init_item_drop_sets()
9997 {
9998
2/2
✓ Branch 0 taken 122880 times.
✓ Branch 1 taken 480 times.
123360 for(int32_t i=0; i<MAXITEMDROPSETS; i++)
9999 {
10000 // item_drop_sets[i] = default_item_drop_sets[0];
10001 122880 memset(&item_drop_sets[i], 0, sizeof(item_drop_object));
10002 122880 }
10003
10004
2/2
✓ Branch 0 taken 6240 times.
✓ Branch 1 taken 480 times.
6720 for(int32_t i=0; i<isMAX; i++)
10005 {
10006 6240 item_drop_sets[i] = default_item_drop_sets[i];
10007
10008 // Deprecated: qr_NOCLOCKS and qr_ALLOW10RUPEEDROPS
10009
2/2
✓ Branch 0 taken 62400 times.
✓ Branch 1 taken 6240 times.
68640 for(int32_t j=0; j<10; ++j)
10010 {
10011 62400 int32_t it = item_drop_sets[i].item[j];
10012
10013
3/4
✓ Branch 0 taken 43884 times.
✓ Branch 1 taken 18516 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2832 times.
62400 if((itemsbuf[it].family == itype_rupee && ((itemsbuf[it].amount)&0xFFF) == 10)
10014
2/2
✓ Branch 0 taken 2832 times.
✓ Branch 1 taken 41052 times.
43884 && !get_bit(deprecated_rules, qr_ALLOW10RUPEEDROPS_DEP))
10015 {
10016 2832 item_drop_sets[i].chance[j+1]=0;
10017 2832 }
10018
4/4
✓ Branch 0 taken 1920 times.
✓ Branch 1 taken 57648 times.
✓ Branch 2 taken 144 times.
✓ Branch 3 taken 1776 times.
59568 else if(itemsbuf[it].family == itype_clock && get_bit(deprecated_rules, qr_NOCLOCKS_DEP))
10019 {
10020 144 item_drop_sets[i].chance[j+1]=0;
10021 144 }
10022
10023 // From Sept 2007 to Dec 2008, non-gameplay items were prohibited.
10024
2/2
✓ Branch 0 taken 62376 times.
✓ Branch 1 taken 24 times.
62400 if(itemsbuf[it].family == itype_misc)
10025 {
10026 // If a non-gameplay item was selected, then item drop was aborted.
10027 // Reflect this by increasing the 'Nothing' chance accordingly.
10028 24 item_drop_sets[i].chance[0]+=item_drop_sets[i].chance[j+1];
10029 24 item_drop_sets[i].chance[j+1]=0;
10030 24 }
10031 62400 }
10032 6240 }
10033 480 }
10034
10035 480 void init_favorites()
10036 {
10037
2/2
✓ Branch 0 taken 604800 times.
✓ Branch 1 taken 480 times.
605280 for(int32_t i=0; i<MAXFAVORITECOMBOS; i++)
10038 {
10039 604800 favorite_combos[i]=-1;
10040 604800 }
10041 480 }
10042
10043 const char *ctype_name[cMAX]=
10044 {
10045 "cNONE", "cSTAIR", "cCAVE", "cWATER", "cARMOS", "cGRAVE", "cDOCK",
10046 "cUNDEF", "cPUSH_WAIT", "cPUSH_HEAVY", "cPUSH_HW", "cL_STATUE", "cR_STATUE",
10047 "cWALKSLOW", "cCVUP", "cCVDOWN", "cCVLEFT", "cCVRIGHT", "cSWIMWARP", "cDIVEWARP",
10048 "cLADDERHOOKSHOT", "cTRIGNOFLAG", "cTRIGFLAG", "cZELDA", "cSLASH", "cSLASHITEM",
10049 "cPUSH_HEAVY2", "cPUSH_HW2", "cPOUND", "cHSGRAB", "cHSBRIDGE", "cDAMAGE1",
10050 "cDAMAGE2", "cDAMAGE3", "cDAMAGE4", "cC_STATUE", "cTRAP_H", "cTRAP_V", "cTRAP_4",
10051 "cTRAP_LR", "cTRAP_UD", "cPIT", "cHOOKSHOTONLY", "cOVERHEAD", "cNOFLYZONE", "cMIRROR",
10052 "cMIRRORSLASH", "cMIRRORBACKSLASH", "cMAGICPRISM", "cMAGICPRISM4",
10053 "cMAGICSPONGE", "cCAVE2", "cEYEBALL_A", "cEYEBALL_B", "cNOJUMPZONE", "cBUSH",
10054 "cFLOWERS", "cTALLGRASS", "cSHALLOWWATER", "cLOCKBLOCK", "cLOCKBLOCK2",
10055 "cBOSSLOCKBLOCK", "cBOSSLOCKBLOCK2", "cLADDERONLY", "cBSGRAVE",
10056 "cCHEST", "cCHEST2", "cLOCKEDCHEST", "cLOCKEDCHEST2", "cBOSSCHEST", "cBOSSCHEST2",
10057 "cRESET", "cSAVE", "cSAVE2", "cCAVEB", "cCAVEC", "cCAVED",
10058 "cSTAIRB", "cSTAIRC", "cSTAIRD", "cPITB", "cPITC", "cPITD",
10059 "cCAVE2B", "cCAVE2C", "cCAVE2D", "cSWIMWARPB", "cSWIMWARPC", "cSWIMWARPD",
10060 "cDIVEWARPB", "cDIVEWARPC", "cDIVEWARPD", "cSTAIRR", "cPITR",
10061 "cAWARPA", "cAWARPB", "cAWARPC", "cAWARPD", "cAWARPR",
10062 "cSWARPA", "cSWARPB", "cSWARPC", "cSWARPD", "cSWARPR", "cSTRIGNOFLAG", "cSTRIGFLAG",
10063 "cSTEP", "cSTEPSAME", "cSTEPALL", "cSTEPCOPY", "cNOENEMY", "cBLOCKARROW1", "cBLOCKARROW2",
10064 "cBLOCKARROW3", "cBLOCKBRANG1", "cBLOCKBRANG2", "cBLOCKBRANG3", "cBLOCKSBEAM", "cBLOCKALL",
10065 "cBLOCKFIREBALL", "cDAMAGE5", "cDAMAGE6", "cDAMAGE7", "cCHANGE", "cSPINTILE1", "cSPINTILE2",
10066 "cSCREENFREEZE", "cSCREENFREEZEFF", "cNOGROUNDENEMY", "cSLASHNEXT", "cSLASHNEXTITEM", "cBUSHNEXT"
10067 "cSLASHTOUCHY", "cSLASHITEMTOUCHY", "cBUSHTOUCHY", "cFLOWERSTOUCHY", "cTALLGRASSTOUCHY",
10068 "cSLASHNEXTTOUCHY", "cSLASHNEXTITEMTOUCHY", "cBUSHNEXTTOUCHY", "cEYEBALL_4", "cTALLGRASSNEXT",
10069 "cSCRIPT1", "cSCRIPT2", "cSCRIPT3", "cSCRIPT4", "cSCRIPT5",
10070 "cSCRIPT6", "cSCRIPT7", "cSCRIPT8", "cSCRIPT9", "cSCRIPT10",
10071 "cSCRIPT11", "cSCRIPT12", "cSCRIPT13", "cSCRIPT14", "cSCRIPT15",
10072 "cSCRIPT16", "cSCRIPT17", "cSCRIPT18", "cSCRIPT19", "cSCRIPT20"
10073
10074 };
10075
10076 773 int32_t init_combo_classes()
10077 {
10078
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 773 times.
773 zinfo* zi = (load_tmp_zi ? load_tmp_zi : &ZI);
10079
2/2
✓ Branch 0 taken 141459 times.
✓ Branch 1 taken 773 times.
142232 for(int32_t i=0; i<cMAX; i++)
10080 {
10081 141459 combo_class_buf[i] = default_combo_classes[i];
10082
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 141459 times.
141459 if ( char const* nm = zi->getComboTypeName(i) )
10083 {
10084 141459 size_t len = strlen(nm);
10085
2/2
✓ Branch 0 taken 9053376 times.
✓ Branch 1 taken 141459 times.
9194835 for ( size_t q = 0; q < 64; q++ )
10086 {
10087
2/2
✓ Branch 0 taken 2072413 times.
✓ Branch 1 taken 6980963 times.
9053376 combo_class_buf[i].name[q] = (q<len ? nm[q] : 0);
10088 9053376 }
10089 141459 }
10090 141459 }
10091
10092 773 return 0;
10093 }
10094
10095 311 int32_t readherosprites2(PACKFILE *f, int32_t v_herosprites)
10096 {
10097
2/2
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 265 times.
311 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_herosprites);
10098
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 311 times.
311 if (should_skip) return 0;
10099
10100
1/2
✓ Branch 0 taken 311 times.
✗ Branch 1 not taken.
311 assert(v_herosprites < 6);
10101
10102 311 zinit.hero_swim_speed=67; //default
10103 311 setupherotiles(zinit.heroAnimationStyle);
10104 311 setupherodefenses();
10105 311 setupherooffsets();
10106
10107
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 206 times.
311 if(v_herosprites>=0)
10108 {
10109 word tile, tile2;
10110 byte flip, extend, dummy_byte;
10111
10112
2/2
✓ Branch 0 taken 824 times.
✓ Branch 1 taken 206 times.
1030 for(int32_t i=0; i<4; i++)
10113 {
10114
1/2
✓ Branch 0 taken 824 times.
✗ Branch 1 not taken.
824 if(!p_igetw(&tile,f))
10115 {
10116 return qe_invalid;
10117 }
10118
10119
1/2
✓ Branch 0 taken 824 times.
✗ Branch 1 not taken.
824 if(!p_getc(&flip,f))
10120 {
10121 return qe_invalid;
10122 }
10123
10124
1/2
✓ Branch 0 taken 824 times.
✗ Branch 1 not taken.
824 if(!p_getc(&extend,f))
10125 {
10126 return qe_invalid;
10127 }
10128
10129 824 walkspr[i][spr_tile]=(int32_t)tile;
10130 824 walkspr[i][spr_flip]=(int32_t)flip;
10131 824 walkspr[i][spr_extend]=(int32_t)extend;
10132 824 }
10133
10134
2/2
✓ Branch 0 taken 824 times.
✓ Branch 1 taken 206 times.
1030 for(int32_t i=0; i<4; i++)
10135 {
10136
1/2
✓ Branch 0 taken 824 times.
✗ Branch 1 not taken.
824 if(!p_igetw(&tile,f))
10137 {
10138 return qe_invalid;
10139 }
10140
10141
1/2
✓ Branch 0 taken 824 times.
✗ Branch 1 not taken.
824 if(!p_getc(&flip,f))
10142 {
10143 return qe_invalid;
10144 }
10145
10146
1/2
✓ Branch 0 taken 824 times.
✗ Branch 1 not taken.
824 if(!p_getc(&extend,f))
10147 {
10148 return qe_invalid;
10149 }
10150
10151 824 stabspr[i][spr_tile]=(int32_t)tile;
10152 824 stabspr[i][spr_flip]=(int32_t)flip;
10153 824 stabspr[i][spr_extend]=(int32_t)extend;
10154 824 }
10155
10156
2/2
✓ Branch 0 taken 824 times.
✓ Branch 1 taken 206 times.
1030 for(int32_t i=0; i<4; i++)
10157 {
10158
1/2
✓ Branch 0 taken 824 times.
✗ Branch 1 not taken.
824 if(!p_igetw(&tile,f))
10159 {
10160 return qe_invalid;
10161 }
10162
10163
1/2
✓ Branch 0 taken 824 times.
✗ Branch 1 not taken.
824 if(!p_getc(&flip,f))
10164 {
10165 return qe_invalid;
10166 }
10167
10168
1/2
✓ Branch 0 taken 824 times.
✗ Branch 1 not taken.
824 if(!p_getc(&extend,f))
10169 {
10170 return qe_invalid;
10171 }
10172
10173 824 slashspr[i][spr_tile]=(int32_t)tile;
10174 824 slashspr[i][spr_flip]=(int32_t)flip;
10175 824 slashspr[i][spr_extend]=(int32_t)extend;
10176 824 }
10177
10178
2/2
✓ Branch 0 taken 824 times.
✓ Branch 1 taken 206 times.
1030 for(int32_t i=0; i<4; i++)
10179 {
10180
1/2
✓ Branch 0 taken 824 times.
✗ Branch 1 not taken.
824 if(!p_igetw(&tile,f))
10181 {
10182 return qe_invalid;
10183 }
10184
10185
1/2
✓ Branch 0 taken 824 times.
✗ Branch 1 not taken.
824 if(!p_getc(&flip,f))
10186 {
10187 return qe_invalid;
10188 }
10189
10190
1/2
✓ Branch 0 taken 824 times.
✗ Branch 1 not taken.
824 if(!p_getc(&extend,f))
10191 {
10192 return qe_invalid;
10193 }
10194
10195 824 floatspr[i][spr_tile]=(int32_t)tile;
10196 824 floatspr[i][spr_flip]=(int32_t)flip;
10197 824 floatspr[i][spr_extend]=(int32_t)extend;
10198 824 }
10199
10200
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 206 times.
206 if(v_herosprites>1)
10201 {
10202
2/2
✓ Branch 0 taken 824 times.
✓ Branch 1 taken 206 times.
1030 for(int32_t i=0; i<4; i++)
10203 {
10204
1/2
✓ Branch 0 taken 824 times.
✗ Branch 1 not taken.
824 if(!p_igetw(&tile,f))
10205 {
10206 return qe_invalid;
10207 }
10208
10209
1/2
✓ Branch 0 taken 824 times.
✗ Branch 1 not taken.
824 if(!p_getc(&flip,f))
10210 {
10211 return qe_invalid;
10212 }
10213
10214
1/2
✓ Branch 0 taken 824 times.
✗ Branch 1 not taken.
824 if(!p_getc(&extend,f))
10215 {
10216 return qe_invalid;
10217 }
10218
10219 824 swimspr[i][spr_tile]=(int32_t)tile;
10220 824 swimspr[i][spr_flip]=(int32_t)flip;
10221 824 swimspr[i][spr_extend]=(int32_t)extend;
10222 824 }
10223 206 }
10224
10225
2/2
✓ Branch 0 taken 824 times.
✓ Branch 1 taken 206 times.
1030 for(int32_t i=0; i<4; i++)
10226 {
10227
1/2
✓ Branch 0 taken 824 times.
✗ Branch 1 not taken.
824 if(!p_igetw(&tile,f))
10228 {
10229 return qe_invalid;
10230 }
10231
10232
1/2
✓ Branch 0 taken 824 times.
✗ Branch 1 not taken.
824 if(!p_getc(&flip,f))
10233 {
10234 return qe_invalid;
10235 }
10236
10237
1/2
✓ Branch 0 taken 824 times.
✗ Branch 1 not taken.
824 if(!p_getc(&extend,f))
10238 {
10239 return qe_invalid;
10240 }
10241
10242 824 divespr[i][spr_tile]=(int32_t)tile;
10243 824 divespr[i][spr_flip]=(int32_t)flip;
10244 824 divespr[i][spr_extend]=(int32_t)extend;
10245 824 }
10246
10247
2/2
✓ Branch 0 taken 824 times.
✓ Branch 1 taken 206 times.
1030 for(int32_t i=0; i<4; i++)
10248 {
10249
1/2
✓ Branch 0 taken 824 times.
✗ Branch 1 not taken.
824 if(!p_igetw(&tile,f))
10250 {
10251 return qe_invalid;
10252 }
10253
10254
1/2
✓ Branch 0 taken 824 times.
✗ Branch 1 not taken.
824 if(!p_getc(&flip,f))
10255 {
10256 return qe_invalid;
10257 }
10258
10259
1/2
✓ Branch 0 taken 824 times.
✗ Branch 1 not taken.
824 if(!p_getc(&extend,f))
10260 {
10261 return qe_invalid;
10262 }
10263
10264 824 poundspr[i][spr_tile]=(int32_t)tile;
10265 824 poundspr[i][spr_flip]=(int32_t)flip;
10266 824 poundspr[i][spr_extend]=(int32_t)extend;
10267 824 }
10268
10269
1/2
✓ Branch 0 taken 206 times.
✗ Branch 1 not taken.
206 if(!p_igetw(&tile,f))
10270 {
10271 return qe_invalid;
10272 }
10273
10274 206 flip=0;
10275
10276
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 206 times.
206 if(v_herosprites>0)
10277 {
10278
1/2
✓ Branch 0 taken 206 times.
✗ Branch 1 not taken.
206 if(!p_getc(&flip,f))
10279 {
10280 return qe_invalid;
10281 }
10282 206 }
10283
10284
1/2
✓ Branch 0 taken 206 times.
✗ Branch 1 not taken.
206 if(!p_getc(&extend,f))
10285 {
10286 return qe_invalid;
10287 }
10288
10289 206 castingspr[spr_tile]=(int32_t)tile;
10290 206 castingspr[spr_flip]=(int32_t)flip;
10291 206 castingspr[spr_extend]=(int32_t)extend;
10292
10293
1/2
✓ Branch 0 taken 206 times.
✗ Branch 1 not taken.
206 if(v_herosprites>0)
10294 {
10295 206 int32_t num_holdsprs = (v_herosprites > 6 ? 3 : 2);
10296
2/2
✓ Branch 0 taken 412 times.
✓ Branch 1 taken 206 times.
618 for(int32_t i=0; i<2; i++)
10297 {
10298
2/2
✓ Branch 0 taken 824 times.
✓ Branch 1 taken 412 times.
1236 for(int32_t j=0; j<num_holdsprs; j++)
10299 {
10300
1/2
✓ Branch 0 taken 824 times.
✗ Branch 1 not taken.
824 if(!p_igetw(&tile,f))
10301 {
10302 return qe_invalid;
10303 }
10304
10305
1/2
✓ Branch 0 taken 824 times.
✗ Branch 1 not taken.
824 if(!p_getc(&flip,f))
10306 {
10307 return qe_invalid;
10308 }
10309
10310
1/2
✓ Branch 0 taken 824 times.
✗ Branch 1 not taken.
824 if(!p_getc(&extend,f))
10311 {
10312 return qe_invalid;
10313 }
10314
10315 824 holdspr[i][j][spr_tile]=(int32_t)tile;
10316 824 holdspr[i][j][spr_flip]=(int32_t)flip;
10317 824 holdspr[i][j][spr_extend]=(int32_t)extend;
10318 824 }
10319 412 }
10320 206 }
10321 else
10322 {
10323 for(int32_t i=0; i<2; i++)
10324 {
10325 if(!p_igetw(&tile,f))
10326 {
10327 return qe_invalid;
10328 }
10329
10330 if(!p_igetw(&tile2,f))
10331 {
10332 return qe_invalid;
10333 }
10334
10335 if(!p_getc(&extend,f))
10336 {
10337 return qe_invalid;
10338 }
10339
10340 holdspr[i][spr_hold1][spr_tile]=(int32_t)tile;
10341 holdspr[i][spr_hold1][spr_flip]=(int32_t)flip;
10342 holdspr[i][spr_hold1][spr_extend]=(int32_t)extend;
10343 holdspr[i][spr_hold2][spr_tile]=(int32_t)tile2;
10344 holdspr[i][spr_hold2][spr_flip]=(int32_t)flip;
10345 holdspr[i][spr_hold2][spr_extend]=(int32_t)extend;
10346 }
10347 }
10348
10349
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 206 times.
206 if(v_herosprites>2)
10350 {
10351
2/2
✓ Branch 0 taken 824 times.
✓ Branch 1 taken 206 times.
1030 for(int32_t i=0; i<4; i++)
10352 {
10353
1/2
✓ Branch 0 taken 824 times.
✗ Branch 1 not taken.
824 if(!p_igetw(&tile,f))
10354 {
10355 return qe_invalid;
10356 }
10357
10358
1/2
✓ Branch 0 taken 824 times.
✗ Branch 1 not taken.
824 if(!p_getc(&flip,f))
10359 {
10360 return qe_invalid;
10361 }
10362
10363
1/2
✓ Branch 0 taken 824 times.
✗ Branch 1 not taken.
824 if(!p_getc(&extend,f))
10364 {
10365 return qe_invalid;
10366 }
10367
10368 824 jumpspr[i][spr_tile]=(int32_t)tile;
10369 824 jumpspr[i][spr_flip]=(int32_t)flip;
10370 824 jumpspr[i][spr_extend]=(int32_t)extend;
10371 824 }
10372 206 }
10373
10374
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 206 times.
206 if(v_herosprites>3)
10375 {
10376
2/2
✓ Branch 0 taken 824 times.
✓ Branch 1 taken 206 times.
1030 for(int32_t i=0; i<4; i++)
10377 {
10378
1/2
✓ Branch 0 taken 824 times.
✗ Branch 1 not taken.
824 if(!p_igetw(&tile,f))
10379 {
10380 return qe_invalid;
10381 }
10382
10383
1/2
✓ Branch 0 taken 824 times.
✗ Branch 1 not taken.
824 if(!p_getc(&flip,f))
10384 {
10385 return qe_invalid;
10386 }
10387
10388
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 824 times.
824 if(!p_getc(&extend,f))
10389 {
10390 return qe_invalid;
10391 }
10392
10393 824 chargespr[i][spr_tile]=(int32_t)tile;
10394 824 chargespr[i][spr_flip]=(int32_t)flip;
10395 824 chargespr[i][spr_extend]=(int32_t)extend;
10396 824 }
10397 206 }
10398
10399
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 206 times.
206 if(v_herosprites>4)
10400 {
10401
1/2
✓ Branch 0 taken 206 times.
✗ Branch 1 not taken.
206 if(!p_getc(&dummy_byte,f))
10402 {
10403 return qe_invalid;
10404 }
10405
10406 206 zinit.hero_swim_speed=(byte)dummy_byte;
10407 206 }
10408
10409 206 memset(frozenspr, 0, sizeof(frozenspr));
10410 206 memset(frozen_waterspr, 0, sizeof(frozen_waterspr));
10411 206 memset(onfirespr, 0, sizeof(onfirespr));
10412 206 memset(onfire_waterspr, 0, sizeof(onfire_waterspr));
10413 206 memset(diggingspr, 0, sizeof(diggingspr));
10414 206 memset(usingrodspr, 0, sizeof(usingrodspr));
10415 206 memset(usingcanespr, 0, sizeof(usingcanespr));
10416 206 memset(pushingspr, 0, sizeof(pushingspr));
10417 206 memset(liftingspr, 0, sizeof(liftingspr));
10418 206 memset(liftingwalkspr, 0, sizeof(liftingwalkspr));
10419 206 memset(stunnedspr, 0, sizeof(stunnedspr));
10420 206 memset(stunned_waterspr, 0, sizeof(stunned_waterspr));
10421 206 memset(fallingspr, 0, sizeof(fallingspr));
10422 206 memset(shockedspr, 0, sizeof(shockedspr));
10423 206 memset(shocked_waterspr, 0, sizeof(shocked_waterspr));
10424 206 memset(pullswordspr, 0, sizeof(pullswordspr));
10425 206 memset(readingspr, 0, sizeof(readingspr));
10426 206 memset(slash180spr, 0, sizeof(slash180spr));
10427 206 memset(slashZ4spr, 0, sizeof(slashZ4spr));
10428 206 memset(dashspr, 0, sizeof(dashspr));
10429 206 memset(bonkspr, 0, sizeof(bonkspr));
10430 206 memset(medallionsprs, 0, sizeof(medallionsprs));
10431 206 memset(holdspr[0][2], 0, sizeof(holdspr[0][2])); //Sword hold (Land)
10432 206 memset(holdspr[1][2], 0, sizeof(holdspr[1][2])); //Sword hold (Water)
10433
2/2
✓ Branch 0 taken 824 times.
✓ Branch 1 taken 206 times.
1030 for(int32_t q = 0; q < 4; ++q)
10434 {
10435
2/2
✓ Branch 0 taken 2472 times.
✓ Branch 1 taken 824 times.
3296 for(int32_t p = 0; p < 3; ++p)
10436 {
10437 2472 drowningspr[q][p] = divespr[q][p];
10438 2472 drowning_lavaspr[q][p] = divespr[q][p];
10439 2472 }
10440 824 }
10441 206 memset(sideswimspr, 0, sizeof(sideswimspr));
10442 206 memset(sideswimslashspr, 0, sizeof(sideswimslashspr));
10443 206 memset(sideswimstabspr, 0, sizeof(sideswimstabspr));
10444 206 memset(sideswimpoundspr, 0, sizeof(sideswimpoundspr));
10445 206 memset(sideswimchargespr, 0, sizeof(sideswimchargespr));
10446 206 memset(sideswimholdspr, 0, sizeof(sideswimholdspr));
10447 206 memset(sidedrowningspr, 0, sizeof(sidedrowningspr));
10448 206 }
10449
10450
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 311 times.
311 if(FFCore.quest_format[vInitData] < 34)
10451 {
10452 311 bool fastswim = zinit.hero_swim_speed > 60;
10453 // '2/3' or '1/2'
10454 311 zinit.hero_swim_mult = fastswim ? 2 : 1;
10455 311 zinit.hero_swim_div = fastswim ? 3 : 2;
10456 311 }
10457 311 return 0;
10458 311 }
10459
10460 32640 void setSprite(int32_t* arr, int32_t tile, int32_t flip, int32_t ext)
10461 {
10462 32640 arr[spr_tile] = tile;
10463
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32640 times.
32640 arr[spr_flip] = (flip > 3 ? 0 : flip);
10464
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32640 times.
32640 arr[spr_extend] = (ext > 2 ? 0 : ext);
10465 32640 }
10466 //Used to read the player sprites as int32_t, not word.
10467 192 int32_t readherosprites3(PACKFILE *f, int32_t v_herosprites)
10468 {
10469 192 zinit.hero_swim_speed=67; //default
10470 192 setupherotiles(zinit.heroAnimationStyle);
10471 192 setupherodefenses();
10472 192 setupherooffsets();
10473
10474 int32_t tile, tile2;
10475 byte flip, extend, dummy_byte;
10476
10477
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if(v_herosprites>=0)
10478 {
10479
10480
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 192 times.
960 for(int32_t i=0; i<4; i++)
10481 {
10482
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetl(&tile,f))
10483 {
10484 return qe_invalid;
10485 }
10486
10487
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 768 times.
768 if(!p_getc(&flip,f))
10488 {
10489 return qe_invalid;
10490 }
10491
10492
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 768 times.
768 if(!p_getc(&extend,f))
10493 {
10494 return qe_invalid;
10495 }
10496
10497 768 setSprite(walkspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10498 768 }
10499
10500
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 192 times.
960 for(int32_t i=0; i<4; i++)
10501 {
10502
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetl(&tile,f))
10503 {
10504 return qe_invalid;
10505 }
10506
10507
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 768 times.
768 if(!p_getc(&flip,f))
10508 {
10509 return qe_invalid;
10510 }
10511
10512
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 768 times.
768 if(!p_getc(&extend,f))
10513 {
10514 return qe_invalid;
10515 }
10516
10517 768 setSprite(stabspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10518 768 }
10519
10520
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 192 times.
960 for(int32_t i=0; i<4; i++)
10521 {
10522
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetl(&tile,f))
10523 {
10524 return qe_invalid;
10525 }
10526
10527
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 768 times.
768 if(!p_getc(&flip,f))
10528 {
10529 return qe_invalid;
10530 }
10531
10532
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 768 times.
768 if(!p_getc(&extend,f))
10533 {
10534 return qe_invalid;
10535 }
10536
10537 768 setSprite(slashspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10538 768 }
10539
10540
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 192 times.
960 for(int32_t i=0; i<4; i++)
10541 {
10542
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetl(&tile,f))
10543 {
10544 return qe_invalid;
10545 }
10546
10547
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 768 times.
768 if(!p_getc(&flip,f))
10548 {
10549 return qe_invalid;
10550 }
10551
10552
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 768 times.
768 if(!p_getc(&extend,f))
10553 {
10554 return qe_invalid;
10555 }
10556
10557 768 setSprite(floatspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10558 768 }
10559
10560
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if(v_herosprites>1)
10561 {
10562
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 192 times.
960 for(int32_t i=0; i<4; i++)
10563 {
10564
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetl(&tile,f))
10565 {
10566 return qe_invalid;
10567 }
10568
10569
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 768 times.
768 if(!p_getc(&flip,f))
10570 {
10571 return qe_invalid;
10572 }
10573
10574
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 768 times.
768 if(!p_getc(&extend,f))
10575 {
10576 return qe_invalid;
10577 }
10578
10579 768 setSprite(swimspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10580 768 }
10581 192 }
10582
10583
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 192 times.
960 for(int32_t i=0; i<4; i++)
10584 {
10585
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetl(&tile,f))
10586 {
10587 return qe_invalid;
10588 }
10589
10590
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 768 times.
768 if(!p_getc(&flip,f))
10591 {
10592 return qe_invalid;
10593 }
10594
10595
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 768 times.
768 if(!p_getc(&extend,f))
10596 {
10597 return qe_invalid;
10598 }
10599
10600 768 setSprite(divespr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10601 768 }
10602
10603
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 192 times.
960 for(int32_t i=0; i<4; i++)
10604 {
10605
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetl(&tile,f))
10606 {
10607 return qe_invalid;
10608 }
10609
10610
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 768 times.
768 if(!p_getc(&flip,f))
10611 {
10612 return qe_invalid;
10613 }
10614
10615
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 768 times.
768 if(!p_getc(&extend,f))
10616 {
10617 return qe_invalid;
10618 }
10619
10620 768 setSprite(poundspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10621 768 }
10622
10623
1/2
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
192 if(!p_igetl(&tile,f))
10624 {
10625 return qe_invalid;
10626 }
10627
10628 192 flip=0;
10629
10630
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if(v_herosprites>0)
10631 {
10632
1/2
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
192 if(!p_getc(&flip,f))
10633 {
10634 return qe_invalid;
10635 }
10636 192 }
10637
10638
1/2
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
192 if(!p_getc(&extend,f))
10639 {
10640 return qe_invalid;
10641 }
10642
10643 192 setSprite(castingspr, int32_t(tile), int32_t(flip), int32_t(extend));
10644
10645
1/2
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
192 if(v_herosprites>0)
10646 {
10647 192 int32_t num_holdsprs = (v_herosprites > 6 ? 3 : 2);
10648
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 192 times.
576 for(int32_t i=0; i<2; i++)
10649 {
10650
2/2
✓ Branch 0 taken 1152 times.
✓ Branch 1 taken 384 times.
1536 for(int32_t j=0; j<num_holdsprs; j++)
10651 {
10652
1/2
✓ Branch 0 taken 1152 times.
✗ Branch 1 not taken.
1152 if(!p_igetl(&tile,f))
10653 {
10654 return qe_invalid;
10655 }
10656
10657
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1152 times.
1152 if(!p_getc(&flip,f))
10658 {
10659 return qe_invalid;
10660 }
10661
10662
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1152 times.
1152 if(!p_getc(&extend,f))
10663 {
10664 return qe_invalid;
10665 }
10666
10667 1152 setSprite(holdspr[i][j], int32_t(tile), int32_t(flip), int32_t(extend));
10668 1152 }
10669 384 }
10670 192 }
10671 else
10672 {
10673 for(int32_t i=0; i<2; i++)
10674 {
10675 if(!p_igetl(&tile,f))
10676 {
10677 return qe_invalid;
10678 }
10679
10680 if(!p_igetl(&tile2,f))
10681 {
10682 return qe_invalid;
10683 }
10684
10685 if(!p_getc(&extend,f))
10686 {
10687 return qe_invalid;
10688 }
10689
10690 setSprite(holdspr[i][spr_hold1], int32_t(tile), int32_t(flip), int32_t(extend));
10691 setSprite(holdspr[i][spr_hold2], int32_t(tile2), int32_t(flip), int32_t(extend));
10692 }
10693 }
10694
10695
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if(v_herosprites>2)
10696 {
10697
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 192 times.
960 for(int32_t i=0; i<4; i++)
10698 {
10699
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetl(&tile,f))
10700 {
10701 return qe_invalid;
10702 }
10703
10704
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 768 times.
768 if(!p_getc(&flip,f))
10705 {
10706 return qe_invalid;
10707 }
10708
10709
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 768 times.
768 if(!p_getc(&extend,f))
10710 {
10711 return qe_invalid;
10712 }
10713
10714 768 setSprite(jumpspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10715 768 }
10716 192 }
10717
10718
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if(v_herosprites>3)
10719 {
10720
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 192 times.
960 for(int32_t i=0; i<4; i++)
10721 {
10722
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetl(&tile,f))
10723 {
10724 return qe_invalid;
10725 }
10726
10727
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 768 times.
768 if(!p_getc(&flip,f))
10728 {
10729 return qe_invalid;
10730 }
10731
10732
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 768 times.
768 if(!p_getc(&extend,f))
10733 {
10734 return qe_invalid;
10735 }
10736
10737 768 setSprite(chargespr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10738 768 }
10739 192 }
10740
10741
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if(v_herosprites>4)
10742 {
10743
1/2
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
192 if(!p_getc(&dummy_byte,f))
10744 {
10745 return qe_invalid;
10746 }
10747
10748 192 zinit.hero_swim_speed=(byte)dummy_byte;
10749 192 }
10750
10751
1/2
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
192 if(v_herosprites>6)
10752 {
10753
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 192 times.
960 for(int32_t q = 0; q < 4; ++q)
10754 {
10755
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetl(&tile,f))
10756 return qe_invalid;
10757
10758
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 768 times.
768 if(!p_getc(&flip,f))
10759 return qe_invalid;
10760
10761
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 768 times.
768 if(!p_getc(&extend,f))
10762 return qe_invalid;
10763
10764 768 setSprite(frozenspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10765 768 }
10766
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 192 times.
960 for(int32_t q = 0; q < 4; ++q)
10767 {
10768
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetl(&tile,f))
10769 return qe_invalid;
10770
10771
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 768 times.
768 if(!p_getc(&flip,f))
10772 return qe_invalid;
10773
10774
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 768 times.
768 if(!p_getc(&extend,f))
10775 return qe_invalid;
10776
10777 768 setSprite(frozen_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10778 768 }
10779
10780
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 192 times.
960 for(int32_t q = 0; q < 4; ++q)
10781 {
10782
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetl(&tile,f))
10783 return qe_invalid;
10784
10785
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 768 times.
768 if(!p_getc(&flip,f))
10786 return qe_invalid;
10787
10788
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 768 times.
768 if(!p_getc(&extend,f))
10789 return qe_invalid;
10790
10791 768 setSprite(onfirespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10792 768 }
10793
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 192 times.
960 for(int32_t q = 0; q < 4; ++q)
10794 {
10795
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetl(&tile,f))
10796 return qe_invalid;
10797
10798
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 768 times.
768 if(!p_getc(&flip,f))
10799 return qe_invalid;
10800
10801
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 768 times.
768 if(!p_getc(&extend,f))
10802 return qe_invalid;
10803
10804 768 setSprite(onfire_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10805 768 }
10806
10807
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 192 times.
960 for(int32_t q = 0; q < 4; ++q)
10808 {
10809
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetl(&tile,f))
10810 return qe_invalid;
10811
10812
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 768 times.
768 if(!p_getc(&flip,f))
10813 return qe_invalid;
10814
10815
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 768 times.
768 if(!p_getc(&extend,f))
10816 return qe_invalid;
10817
10818 768 setSprite(diggingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10819 768 }
10820
10821
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 192 times.
960 for(int32_t q = 0; q < 4; ++q)
10822 {
10823
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetl(&tile,f))
10824 return qe_invalid;
10825
10826
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_getc(&flip,f))
10827 return qe_invalid;
10828
10829
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 768 times.
768 if(!p_getc(&extend,f))
10830 return qe_invalid;
10831
10832 768 setSprite(usingrodspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10833 768 }
10834
10835
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 192 times.
960 for(int32_t q = 0; q < 4; ++q)
10836 {
10837
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetl(&tile,f))
10838 return qe_invalid;
10839
10840
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_getc(&flip,f))
10841 return qe_invalid;
10842
10843
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_getc(&extend,f))
10844 return qe_invalid;
10845
10846 768 setSprite(usingcanespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10847 768 }
10848
10849
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 192 times.
960 for(int32_t q = 0; q < 4; ++q)
10850 {
10851
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetl(&tile,f))
10852 return qe_invalid;
10853
10854
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 768 times.
768 if(!p_getc(&flip,f))
10855 return qe_invalid;
10856
10857
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 768 times.
768 if(!p_getc(&extend,f))
10858 return qe_invalid;
10859
10860 768 setSprite(pushingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10861 768 }
10862
10863
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 192 times.
960 for(int32_t q = 0; q < 4; ++q)
10864 {
10865
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetl(&tile,f))
10866 return qe_invalid;
10867
10868
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_getc(&flip,f))
10869 return qe_invalid;
10870
10871
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_getc(&extend,f))
10872 return qe_invalid;
10873
10874 768 byte frames = 0;
10875
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 748 times.
768 if(v_herosprites > 15)
10876 {
10877
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 748 times.
748 if(!p_getc(&frames,f))
10878 return qe_invalid;
10879 748 }
10880
10881 768 setSprite(liftingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10882 768 liftingspr[q][spr_frames] = frames;
10883 768 }
10884
10885
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 192 times.
960 for(int32_t q = 0; q < 4; ++q)
10886 {
10887
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetl(&tile,f))
10888 return qe_invalid;
10889
10890
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_getc(&flip,f))
10891 return qe_invalid;
10892
10893
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_getc(&extend,f))
10894 return qe_invalid;
10895
10896 768 setSprite(liftingwalkspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10897 768 }
10898
10899
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 192 times.
960 for(int32_t q = 0; q < 4; ++q)
10900 {
10901
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 768 times.
768 if(!p_igetl(&tile,f))
10902 return qe_invalid;
10903
10904
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_getc(&flip,f))
10905 return qe_invalid;
10906
10907
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 768 times.
768 if(!p_getc(&extend,f))
10908 return qe_invalid;
10909
10910 768 setSprite(stunnedspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10911 768 }
10912
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 192 times.
960 for(int32_t q = 0; q < 4; ++q)
10913 {
10914
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetl(&tile,f))
10915 return qe_invalid;
10916
10917
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_getc(&flip,f))
10918 return qe_invalid;
10919
10920
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_getc(&extend,f))
10921 return qe_invalid;
10922
10923 768 setSprite(stunned_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10924 768 }
10925
10926
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 192 times.
960 for(int32_t q = 0; q < 4; ++q)
10927 {
10928
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetl(&tile,f))
10929 return qe_invalid;
10930
10931
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_getc(&flip,f))
10932 return qe_invalid;
10933
10934
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 768 times.
768 if(!p_getc(&extend,f))
10935 return qe_invalid;
10936
10937 768 setSprite(drowningspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10938 768 }
10939
10940
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 192 times.
960 for(int32_t q = 0; q < 4; ++q)
10941 {
10942
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetl(&tile,f))
10943 return qe_invalid;
10944
10945
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_getc(&flip,f))
10946 return qe_invalid;
10947
10948
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_getc(&extend,f))
10949 return qe_invalid;
10950
10951 768 setSprite(drowning_lavaspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10952 768 }
10953
10954
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 192 times.
960 for(int32_t q = 0; q < 4; ++q)
10955 {
10956
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetl(&tile,f))
10957 return qe_invalid;
10958
10959
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_getc(&flip,f))
10960 return qe_invalid;
10961
10962
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_getc(&extend,f))
10963 return qe_invalid;
10964
10965 768 setSprite(fallingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10966 768 }
10967
10968
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 192 times.
960 for(int32_t q = 0; q < 4; ++q)
10969 {
10970
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetl(&tile,f))
10971 return qe_invalid;
10972
10973
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_getc(&flip,f))
10974 return qe_invalid;
10975
10976
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_getc(&extend,f))
10977 return qe_invalid;
10978
10979 768 setSprite(shockedspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10980 768 }
10981
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 192 times.
960 for(int32_t q = 0; q < 4; ++q)
10982 {
10983
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetl(&tile,f))
10984 return qe_invalid;
10985
10986
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_getc(&flip,f))
10987 return qe_invalid;
10988
10989
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_getc(&extend,f))
10990 return qe_invalid;
10991
10992 768 setSprite(shocked_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10993 768 }
10994
10995
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 192 times.
960 for(int32_t q = 0; q < 4; ++q)
10996 {
10997
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetl(&tile,f))
10998 return qe_invalid;
10999
11000
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 768 times.
768 if(!p_getc(&flip,f))
11001 return qe_invalid;
11002
11003
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 768 times.
768 if(!p_getc(&extend,f))
11004 return qe_invalid;
11005
11006 768 setSprite(pullswordspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11007 768 }
11008
11009
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 192 times.
960 for(int32_t q = 0; q < 4; ++q)
11010 {
11011
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetl(&tile,f))
11012 return qe_invalid;
11013
11014
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_getc(&flip,f))
11015 return qe_invalid;
11016
11017
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_getc(&extend,f))
11018 return qe_invalid;
11019
11020 768 setSprite(readingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11021 768 }
11022
11023
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 192 times.
960 for(int32_t q = 0; q < 4; ++q)
11024 {
11025
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 768 times.
768 if(!p_igetl(&tile,f))
11026 return qe_invalid;
11027
11028
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_getc(&flip,f))
11029 return qe_invalid;
11030
11031
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 768 times.
768 if(!p_getc(&extend,f))
11032 return qe_invalid;
11033
11034 768 setSprite(slash180spr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11035 768 }
11036
11037
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 192 times.
960 for(int32_t q = 0; q < 4; ++q)
11038 {
11039
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetl(&tile,f))
11040 return qe_invalid;
11041
11042
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_getc(&flip,f))
11043 return qe_invalid;
11044
11045
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_getc(&extend,f))
11046 return qe_invalid;
11047
11048 768 setSprite(slashZ4spr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11049 768 }
11050
11051
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 192 times.
960 for(int32_t q = 0; q < 4; ++q)
11052 {
11053
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetl(&tile,f))
11054 return qe_invalid;
11055
11056
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_getc(&flip,f))
11057 return qe_invalid;
11058
11059
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_getc(&extend,f))
11060 return qe_invalid;
11061
11062 768 setSprite(dashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11063 768 }
11064
11065
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 192 times.
960 for(int32_t q = 0; q < 4; ++q)
11066 {
11067
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetl(&tile,f))
11068 return qe_invalid;
11069
11070
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_getc(&flip,f))
11071 return qe_invalid;
11072
11073
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_getc(&extend,f))
11074 return qe_invalid;
11075
11076 768 setSprite(bonkspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11077 768 }
11078
11079
2/2
✓ Branch 0 taken 576 times.
✓ Branch 1 taken 192 times.
768 for(int32_t q = 0; q < 3; ++q) //Not directions; number of medallion sprs
11080 {
11081
1/2
✓ Branch 0 taken 576 times.
✗ Branch 1 not taken.
576 if(!p_igetl(&tile,f))
11082 return qe_invalid;
11083
11084
1/2
✓ Branch 0 taken 576 times.
✗ Branch 1 not taken.
576 if(!p_getc(&flip,f))
11085 return qe_invalid;
11086
11087
1/2
✓ Branch 0 taken 576 times.
✗ Branch 1 not taken.
576 if(!p_getc(&extend,f))
11088 return qe_invalid;
11089
11090 576 setSprite(medallionsprs[q], int32_t(tile), int32_t(flip), int32_t(extend));
11091 576 }
11092 192 }
11093 else
11094 {
11095 memset(frozenspr, 0, sizeof(frozenspr));
11096 memset(frozen_waterspr, 0, sizeof(frozen_waterspr));
11097 memset(onfirespr, 0, sizeof(onfirespr));
11098 memset(onfire_waterspr, 0, sizeof(onfire_waterspr));
11099 memset(diggingspr, 0, sizeof(diggingspr));
11100 memset(usingrodspr, 0, sizeof(usingrodspr));
11101 memset(usingcanespr, 0, sizeof(usingcanespr));
11102 memset(pushingspr, 0, sizeof(pushingspr));
11103 memset(liftingspr, 0, sizeof(liftingspr));
11104 memset(liftingwalkspr, 0, sizeof(liftingwalkspr));
11105 memset(stunnedspr, 0, sizeof(stunnedspr));
11106 memset(stunned_waterspr, 0, sizeof(stunned_waterspr));
11107 memset(fallingspr, 0, sizeof(fallingspr));
11108 memset(shockedspr, 0, sizeof(shockedspr));
11109 memset(shocked_waterspr, 0, sizeof(shocked_waterspr));
11110 memset(pullswordspr, 0, sizeof(pullswordspr));
11111 memset(readingspr, 0, sizeof(readingspr));
11112 memset(slash180spr, 0, sizeof(slash180spr));
11113 memset(slashZ4spr, 0, sizeof(slashZ4spr));
11114 memset(dashspr, 0, sizeof(dashspr));
11115 memset(bonkspr, 0, sizeof(bonkspr));
11116 memset(medallionsprs, 0, sizeof(medallionsprs));
11117 memset(holdspr[0][2], 0, sizeof(holdspr[0][2])); //Sword hold (Land)
11118 memset(holdspr[1][2], 0, sizeof(holdspr[1][2])); //Sword hold (Water)
11119 for(int32_t q = 0; q < 4; ++q)
11120 {
11121 for(int32_t p = 0; p < 3; ++p)
11122 {
11123 drowningspr[q][p] = divespr[q][p];
11124 drowning_lavaspr[q][p] = divespr[q][p];
11125 }
11126 }
11127 }
11128
1/2
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
192 if (v_herosprites > 8)
11129 {
11130
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 192 times.
960 for(int32_t q = 0; q < 4; ++q)
11131 {
11132
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetl(&tile,f))
11133 return qe_invalid;
11134
11135
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 768 times.
768 if(!p_getc(&flip,f))
11136 return qe_invalid;
11137
11138
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 768 times.
768 if(!p_getc(&extend,f))
11139 return qe_invalid;
11140
11141 768 setSprite(sideswimspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11142 768 }
11143 192 }
11144 else
11145 {
11146 memset(sideswimspr, 0, sizeof(sideswimspr));
11147 }
11148
1/2
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
192 if (v_herosprites > 9)
11149 {
11150
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 192 times.
960 for(int32_t q = 0; q < 4; ++q)
11151 {
11152
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetl(&tile,f))
11153 return qe_invalid;
11154
11155
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 768 times.
768 if(!p_getc(&flip,f))
11156 return qe_invalid;
11157
11158
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 768 times.
768 if(!p_getc(&extend,f))
11159 return qe_invalid;
11160
11161 768 setSprite(sideswimslashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11162 768 }
11163
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 192 times.
960 for(int32_t q = 0; q < 4; ++q)
11164 {
11165
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetl(&tile,f))
11166 return qe_invalid;
11167
11168
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 768 times.
768 if(!p_getc(&flip,f))
11169 return qe_invalid;
11170
11171
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 768 times.
768 if(!p_getc(&extend,f))
11172 return qe_invalid;
11173
11174 768 setSprite(sideswimstabspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11175 768 }
11176
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 192 times.
960 for(int32_t q = 0; q < 4; ++q)
11177 {
11178
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetl(&tile,f))
11179 return qe_invalid;
11180
11181
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 768 times.
768 if(!p_getc(&flip,f))
11182 return qe_invalid;
11183
11184
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 768 times.
768 if(!p_getc(&extend,f))
11185 return qe_invalid;
11186
11187 768 setSprite(sideswimpoundspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11188 768 }
11189
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 192 times.
960 for(int32_t q = 0; q < 4; ++q)
11190 {
11191
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetl(&tile,f))
11192 return qe_invalid;
11193
11194
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 768 times.
768 if(!p_getc(&flip,f))
11195 return qe_invalid;
11196
11197
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 768 times.
768 if(!p_getc(&extend,f))
11198 return qe_invalid;
11199
11200 768 setSprite(sideswimchargespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11201 768 }
11202 192 }
11203 else
11204 {
11205 memset(sideswimslashspr, 0, sizeof(sideswimslashspr));
11206 memset(sideswimstabspr, 0, sizeof(sideswimstabspr));
11207 memset(sideswimpoundspr, 0, sizeof(sideswimpoundspr));
11208 memset(sideswimchargespr, 0, sizeof(sideswimchargespr));
11209 }
11210
1/2
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
192 if (v_herosprites > 10)
11211 {
11212
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 192 times.
960 for(int32_t q = 0; q < 4; ++q)
11213 {
11214 int32_t hmr;
11215
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 768 times.
768 if(!p_igetl(&hmr,f))
11216 return qe_invalid;
11217
11218 768 hammeroffsets[q] = hmr;
11219 768 }
11220 192 }
11221 else
11222 {
11223 for(int32_t q = 0; q < 4; ++q) hammeroffsets[q] = 0;
11224 }
11225
1/2
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
192 if (v_herosprites > 11)
11226 {
11227
2/2
✓ Branch 0 taken 576 times.
✓ Branch 1 taken 192 times.
768 for(int32_t q = 0; q < 3; ++q)
11228 {
11229
1/2
✓ Branch 0 taken 576 times.
✗ Branch 1 not taken.
576 if(!p_igetl(&tile,f))
11230 return qe_invalid;
11231
11232
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 576 times.
576 if(!p_getc(&flip,f))
11233 return qe_invalid;
11234
11235
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 576 times.
576 if(!p_getc(&extend,f))
11236 return qe_invalid;
11237
11238 576 setSprite(sideswimholdspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11239 576 }
11240 192 }
11241 else
11242 {
11243 memset(sideswimholdspr, 0, sizeof(sideswimholdspr));
11244 }
11245
1/2
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
192 if (v_herosprites > 12)
11246 {
11247
1/2
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
192 if(!p_igetl(&tile,f))
11248 return qe_invalid;
11249
11250
1/2
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
192 if(!p_getc(&flip,f))
11251 return qe_invalid;
11252
11253
1/2
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
192 if(!p_getc(&extend,f))
11254 return qe_invalid;
11255 192 setSprite(sideswimcastingspr, int32_t(tile), int32_t(flip), int32_t(extend));
11256
11257 192 }
11258 else
11259 {
11260 memset(sideswimcastingspr, 0, sizeof(sideswimcastingspr));
11261 }
11262
1/2
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
192 if (v_herosprites > 13)
11263 {
11264
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 192 times.
960 for(int32_t q = 0; q < 4; ++q)
11265 {
11266
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetl(&tile,f))
11267 return qe_invalid;
11268
11269
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 768 times.
768 if(!p_getc(&flip,f))
11270 return qe_invalid;
11271
11272
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 768 times.
768 if(!p_getc(&extend,f))
11273 return qe_invalid;
11274
11275 768 setSprite(sidedrowningspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11276 768 }
11277 192 }
11278 else
11279 {
11280 memset(sidedrowningspr, 0, sizeof(sidedrowningspr));
11281 }
11282
1/2
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
192 if (v_herosprites > 14)
11283 {
11284
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 192 times.
960 for(int32_t q = 0; q < 4; ++q)
11285 {
11286
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetl(&tile,f))
11287 return qe_invalid;
11288
11289
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 768 times.
768 if(!p_getc(&flip,f))
11290 return qe_invalid;
11291
11292
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 768 times.
768 if(!p_getc(&extend,f))
11293 return qe_invalid;
11294
11295 768 setSprite(revslashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11296 768 }
11297 192 }
11298 else
11299 {
11300 memset(revslashspr, 0, sizeof(revslashspr));
11301 }
11302
1/2
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
192 if (v_herosprites > 7)
11303 {
11304 192 int32_t num_defense = wMax;
11305 192 byte def = 0;
11306
11307 //Set num_defense accordingly if changes to enum require version upgrade - Jman
11308 /*if(v_herosprites > [x])
11309 * {
11310 * num_defense = 146 //value of wMax on version 8
11311 * }
11312 */
11313
11314
2/2
✓ Branch 0 taken 28032 times.
✓ Branch 1 taken 192 times.
28224 for (int32_t q = 0; q < num_defense; q++)
11315 {
11316
1/2
✓ Branch 0 taken 28032 times.
✗ Branch 1 not taken.
28032 if (!p_getc(&def, f))
11317 return qe_invalid;
11318
11319 28032 hero_defenses[q] = def;
11320 28032 }
11321 192 }
11322 else
11323 {
11324 int32_t num_defense = wMax;
11325 for (int32_t q = 0; q < num_defense; q++)
11326 {
11327 hero_defenses[q] = 0;
11328 }
11329 }
11330 192 }
11331
11332
2/2
✓ Branch 0 taken 181 times.
✓ Branch 1 taken 11 times.
192 if(FFCore.quest_format[vInitData] < 34)
11333 {
11334 11 bool fastswim = zinit.hero_swim_speed > 60;
11335 // '2/3' or '1/2'
11336 11 zinit.hero_swim_mult = fastswim ? 2 : 1;
11337 11 zinit.hero_swim_div = fastswim ? 3 : 2;
11338 11 }
11339 192 return 0;
11340 192 }
11341
11342
11343 398 int32_t readherosprites(PACKFILE *f, zquestheader *Header)
11344 {
11345 //these are here to bypass compiler warnings about unused arguments
11346 398 Header=Header;
11347
11348 dword dummy;
11349 398 word s_version=0;
11350
11351 //section version info
11352
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 if(!p_igetw(&s_version,f))
11353 {
11354 return qe_invalid;
11355 }
11356
11357 398 FFCore.quest_format[vHeroSprites] = s_version;
11358
11359
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!read_deprecated_section_cversion(f))
11360 {
11361 return qe_invalid;
11362 }
11363
11364 //section size
11365
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_igetl(&dummy,f))
11366 {
11367 return qe_invalid;
11368 }
11369
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 206 times.
398 if ( s_version >= 6 )
11370 {
11371 192 return readherosprites3(f, s_version);
11372 }
11373 206 else return readherosprites2(f, s_version);
11374 398 }
11375
11376 223 int32_t read_old_subscreens(PACKFILE *f, word s_version)
11377 {
11378 223 subscreens_active.clear();
11379 223 subscreens_passive.clear();
11380 223 subscreens_overlay.clear();
11381
2/2
✓ Branch 0 taken 28544 times.
✓ Branch 1 taken 223 times.
28767 for(int32_t i=0; i<MAXCUSTOMSUBSCREENS; i++)
11382 {
11383 subscreen_group g;
11384 28544 memset(&g,0,sizeof(subscreen_group));
11385 28544 int32_t ret = read_one_old_subscreen(f, &g, s_version);
11386
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28544 times.
28544 if(ret!=0)
11387 return ret;
11388
2/2
✓ Branch 0 taken 1165 times.
✓ Branch 1 taken 27379 times.
28544 if(g.objects[0].type == ssoNULL) continue;
11389
2/2
✓ Branch 0 taken 487 times.
✓ Branch 1 taken 678 times.
1165 auto& vec = g.ss_type == sstPASSIVE ? subscreens_passive : subscreens_active;
11390 1165 ZCSubscreen& sub = vec.emplace_back();
11391 1165 sub.load_old(g);
11392 1165 }
11393
11394 223 return 0;
11395 223 }
11396
11397 28544 int32_t read_one_old_subscreen(PACKFILE *f, subscreen_group* g, word s_version)
11398 {
11399 28544 int32_t numsub=0;
11400 28544 byte temp_ss=0;
11401 subscreen_object temp_sub_stack;
11402 28544 subscreen_object *temp_sub = &temp_sub_stack;
11403
11404 char tempname[64];
11405
11406 // FWIW I never saw anything bigger than 20.
11407 #define MAX_DP1_LEN 1024
11408 char tempdp1[MAX_DP1_LEN];
11409
11410
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28544 times.
28544 if(!pfread(tempname,64,f))
11411 {
11412 return qe_invalid;
11413 }
11414
11415
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28544 times.
28544 if(s_version > 1)
11416 {
11417
1/2
✓ Branch 0 taken 28544 times.
✗ Branch 1 not taken.
28544 if(!p_getc(&temp_ss,f))
11418 {
11419 return qe_invalid;
11420 }
11421 28544 }
11422
11423
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28544 times.
28544 if(s_version < 4)
11424 {
11425 uint8_t tmp=0;
11426
11427 if(!p_getc(&tmp,f))
11428 {
11429 return qe_invalid;
11430 }
11431
11432 numsub = (int32_t)tmp;
11433 }
11434 else
11435 {
11436 word tmp;
11437
11438
1/2
✓ Branch 0 taken 28544 times.
✗ Branch 1 not taken.
28544 if(!p_igetw(&tmp, f))
11439 {
11440 return qe_invalid;
11441 }
11442
11443 28544 numsub = (int32_t)tmp;
11444 }
11445
11446 int32_t j;
11447
11448
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 75489 times.
✓ Branch 2 taken 46945 times.
✓ Branch 3 taken 28544 times.
75489 for(j=0; (j<MAXSUBSCREENITEMS&&j<numsub); j++)
11449 {
11450 46945 memset(temp_sub,0,sizeof(subscreen_object));
11451
11452
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46945 times.
46945 switch(g->objects[j].type)
11453 {
11454 case ssoTEXT:
11455 case ssoTEXTBOX:
11456 case ssoCURRENTITEMTEXT:
11457 case ssoCURRENTITEMCLASSTEXT:
11458 if(g->objects[j].dp1 != NULL) delete [](char *)g->objects[j].dp1;
11459
11460 //fall through
11461 default:
11462 46945 memset(&g->objects[j],0,sizeof(subscreen_object));
11463 46945 break;
11464 }
11465
11466
1/2
✓ Branch 0 taken 46945 times.
✗ Branch 1 not taken.
46945 if(!p_getc(&(temp_sub->type),f))
11467 return qe_invalid;
11468
11469
1/2
✓ Branch 0 taken 46945 times.
✗ Branch 1 not taken.
46945 if(!p_getc(&(temp_sub->pos),f))
11470 return qe_invalid;
11471
11472
1/2
✓ Branch 0 taken 46945 times.
✗ Branch 1 not taken.
46945 if(s_version < 5)
11473 {
11474 switch(temp_sub->pos)
11475 {
11476 case 0:
11477 temp_sub->pos = sspUP | sspDOWN | sspSCROLLING;
11478 break;
11479
11480 case 1:
11481 temp_sub->pos = sspUP;
11482 break;
11483
11484 case 2:
11485 temp_sub->pos = sspDOWN;
11486 break;
11487
11488 default:
11489 temp_sub->pos = 0;
11490 }
11491 }
11492
11493
1/2
✓ Branch 0 taken 46945 times.
✗ Branch 1 not taken.
46945 if(!p_igetw(&(temp_sub->x),f))
11494 return qe_invalid;
11495
11496
1/2
✓ Branch 0 taken 46945 times.
✗ Branch 1 not taken.
46945 if(!p_igetw(&(temp_sub->y),f))
11497 return qe_invalid;
11498
11499
1/2
✓ Branch 0 taken 46945 times.
✗ Branch 1 not taken.
46945 if(!p_igetw(&(temp_sub->w),f))
11500 return qe_invalid;
11501
11502
1/2
✓ Branch 0 taken 46945 times.
✗ Branch 1 not taken.
46945 if(!p_igetw(&(temp_sub->h),f))
11503 return qe_invalid;
11504
11505
1/2
✓ Branch 0 taken 46945 times.
✗ Branch 1 not taken.
46945 if(!p_getc(&(temp_sub->colortype1),f))
11506 return qe_invalid;
11507
11508
1/2
✓ Branch 0 taken 46945 times.
✗ Branch 1 not taken.
46945 if(!p_igetw(&(temp_sub->color1),f))
11509 return qe_invalid;
11510
11511
1/2
✓ Branch 0 taken 46945 times.
✗ Branch 1 not taken.
46945 if(!p_getc(&(temp_sub->colortype2),f))
11512 return qe_invalid;
11513
11514
1/2
✓ Branch 0 taken 46945 times.
✗ Branch 1 not taken.
46945 if(!p_igetw(&(temp_sub->color2),f))
11515 return qe_invalid;
11516
11517
1/2
✓ Branch 0 taken 46945 times.
✗ Branch 1 not taken.
46945 if(!p_getc(&(temp_sub->colortype3),f))
11518 return qe_invalid;
11519
11520
1/2
✓ Branch 0 taken 46945 times.
✗ Branch 1 not taken.
46945 if(!p_igetw(&(temp_sub->color3),f))
11521 return qe_invalid;
11522
11523
1/2
✓ Branch 0 taken 46945 times.
✗ Branch 1 not taken.
46945 if(!p_igetd(&(temp_sub->d1),f))
11524 return qe_invalid;
11525
11526
1/2
✓ Branch 0 taken 46945 times.
✗ Branch 1 not taken.
46945 if(!p_igetd(&(temp_sub->d2),f))
11527 return qe_invalid;
11528
11529
1/2
✓ Branch 0 taken 46945 times.
✗ Branch 1 not taken.
46945 if(!p_igetd(&(temp_sub->d3),f))
11530 return qe_invalid;
11531
11532
1/2
✓ Branch 0 taken 46945 times.
✗ Branch 1 not taken.
46945 if(!p_igetd(&(temp_sub->d4),f))
11533 return qe_invalid;
11534
11535
1/2
✓ Branch 0 taken 46945 times.
✗ Branch 1 not taken.
46945 if(!p_igetd(&(temp_sub->d5),f))
11536 return qe_invalid;
11537
11538
1/2
✓ Branch 0 taken 46945 times.
✗ Branch 1 not taken.
46945 if(!p_igetd(&(temp_sub->d6),f))
11539 return qe_invalid;
11540
11541
1/2
✓ Branch 0 taken 46945 times.
✗ Branch 1 not taken.
46945 if(!p_igetd(&(temp_sub->d7),f))
11542 return qe_invalid;
11543
11544
1/2
✓ Branch 0 taken 46945 times.
✗ Branch 1 not taken.
46945 if(!p_igetd(&(temp_sub->d8),f))
11545 return qe_invalid;
11546
11547
1/2
✓ Branch 0 taken 46945 times.
✗ Branch 1 not taken.
46945 if(!p_igetd(&(temp_sub->d9),f))
11548 return qe_invalid;
11549
11550
1/2
✓ Branch 0 taken 46945 times.
✗ Branch 1 not taken.
46945 if(!p_igetd(&(temp_sub->d10),f))
11551 return qe_invalid;
11552
11553
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46945 times.
46945 if(s_version < 2)
11554 {
11555 if(!p_igetl(&(temp_sub->speed),f))
11556 return qe_invalid;
11557
11558 if(!p_igetl(&(temp_sub->delay),f))
11559 return qe_invalid;
11560
11561 if(!p_igetl(&(temp_sub->frame),f))
11562 return qe_invalid;
11563 }
11564 else
11565 {
11566
1/2
✓ Branch 0 taken 46945 times.
✗ Branch 1 not taken.
46945 if(!p_getc(&(temp_sub->speed),f))
11567 return qe_invalid;
11568
11569
1/2
✓ Branch 0 taken 46945 times.
✗ Branch 1 not taken.
46945 if(!p_getc(&(temp_sub->delay),f))
11570 return qe_invalid;
11571
11572
1/2
✓ Branch 0 taken 46945 times.
✗ Branch 1 not taken.
46945 if(!p_igetw(&(temp_sub->frame),f))
11573 return qe_invalid;
11574 }
11575
11576 46945 int32_t temp_size=0;
11577
11578 // bool deletets = false;
11579
4/4
✓ Branch 0 taken 20862 times.
✓ Branch 1 taken 3497 times.
✓ Branch 2 taken 22334 times.
✓ Branch 3 taken 252 times.
46945 switch(temp_sub->type)
11580 {
11581 case ssoTEXT:
11582 case ssoTEXTBOX:
11583 case ssoCURRENTITEMTEXT:
11584 case ssoCURRENTITEMCLASSTEXT:
11585 {
11586 word temptempsize;
11587
11588
1/2
✓ Branch 0 taken 3497 times.
✗ Branch 1 not taken.
3497 if(!p_igetw(&temptempsize,f))
11589 {
11590 return qe_invalid;
11591 }
11592
11593 //temptempsize = temp1 + (temp2 << 8);
11594 3497 temp_size = (int32_t)temptempsize;
11595 3497 uint32_t char_length = temp_size+2;
11596
1/2
✓ Branch 0 taken 3497 times.
✗ Branch 1 not taken.
3497 if (char_length > MAX_DP1_LEN)
11597 {
11598 return qe_invalid;
11599 }
11600 3497 tempdp1[char_length - 1] = '\0';
11601
11602
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3497 times.
3497 if(temp_size)
11603
1/2
✓ Branch 0 taken 3497 times.
✗ Branch 1 not taken.
3497 if(!pfread(tempdp1,temp_size+1,f))
11604 return qe_invalid;
11605 3497 break;
11606 }
11607
11608 case ssoLIFEMETER:
11609
1/2
✓ Branch 0 taken 252 times.
✗ Branch 1 not taken.
252 if(get_bit(deprecated_rules, 12) != 0) // qr_24HC
11610 temp_sub->d3 = 1;
11611
11612
1/2
✓ Branch 0 taken 252 times.
✗ Branch 1 not taken.
252 if(!p_getc(&(temp_sub->dp1),f))
11613 return qe_invalid;
11614
11615 252 break;
11616
11617
11618 case ssoCURRENTITEM:
11619
11620
1/2
✓ Branch 0 taken 20862 times.
✗ Branch 1 not taken.
20862 if(s_version < 6)
11621 {
11622 switch(temp_sub->d1)
11623 {
11624 case ssiBOMB:
11625 temp_sub->d1 = itype_bomb;
11626 break;
11627
11628 case ssiSWORD:
11629 temp_sub->d1 = itype_sword;
11630 break;
11631
11632 case ssiSHIELD:
11633 temp_sub->d1 = itype_shield;
11634 break;
11635
11636 case ssiCANDLE:
11637 temp_sub->d1 = itype_candle;
11638 break;
11639
11640 case ssiLETTER:
11641 temp_sub->d1 = itype_letter;
11642 break;
11643
11644 case ssiPOTION:
11645 temp_sub->d1 = itype_potion;
11646 break;
11647
11648 case ssiLETTERPOTION:
11649 temp_sub->d1 = itype_letterpotion;
11650 break;
11651
11652 case ssiBOW:
11653 temp_sub->d1 = itype_bow;
11654 break;
11655
11656 case ssiARROW:
11657 temp_sub->d1 = itype_arrow;
11658 break;
11659
11660 case ssiBOWANDARROW:
11661 temp_sub->d1 = itype_bowandarrow;
11662 break;
11663
11664 case ssiBAIT:
11665 temp_sub->d1 = itype_bait;
11666 break;
11667
11668 case ssiRING:
11669 temp_sub->d1 = itype_ring;
11670 break;
11671
11672 case ssiBRACELET:
11673 temp_sub->d1 = itype_bracelet;
11674 break;
11675
11676 case ssiMAP:
11677 temp_sub->d1 = itype_map;
11678 break;
11679
11680 case ssiCOMPASS:
11681 temp_sub->d1 = itype_compass;
11682 break;
11683
11684 case ssiBOSSKEY:
11685 temp_sub->d1 = itype_bosskey;
11686 break;
11687
11688 case ssiMAGICKEY:
11689 temp_sub->d1 = itype_magickey;
11690 break;
11691
11692 case ssiBRANG:
11693 temp_sub->d1 = itype_brang;
11694 break;
11695
11696 case ssiWAND:
11697 temp_sub->d1 = itype_wand;
11698 break;
11699
11700 case ssiRAFT:
11701 temp_sub->d1 = itype_raft;
11702 break;
11703
11704 case ssiLADDER:
11705 temp_sub->d1 = itype_ladder;
11706 break;
11707
11708 case ssiWHISTLE:
11709 temp_sub->d1 = itype_whistle;
11710 break;
11711
11712 case ssiBOOK:
11713 temp_sub->d1 = itype_book;
11714 break;
11715
11716 case ssiWALLET:
11717 temp_sub->d1 = itype_wallet;
11718 break;
11719
11720 case ssiSBOMB:
11721 temp_sub->d1 = itype_sbomb;
11722 break;
11723
11724 case ssiHCPIECE:
11725 temp_sub->d1 = itype_heartpiece;
11726 break;
11727
11728 case ssiAMULET:
11729 temp_sub->d1 = itype_amulet;
11730 break;
11731
11732 case ssiFLIPPERS:
11733 temp_sub->d1 = itype_flippers;
11734 break;
11735
11736 case ssiHOOKSHOT:
11737 temp_sub->d1 = itype_hookshot;
11738 break;
11739
11740 case ssiLENS:
11741 temp_sub->d1 = itype_lens;
11742 break;
11743
11744 case ssiHAMMER:
11745 temp_sub->d1 = itype_hammer;
11746 break;
11747
11748 case ssiBOOTS:
11749 temp_sub->d1 = itype_boots;
11750 break;
11751
11752 case ssiDIVINEFIRE:
11753 temp_sub->d1 = itype_divinefire;
11754 break;
11755
11756 case ssiDIVINEESCAPE:
11757 temp_sub->d1 = itype_divineescape;
11758 break;
11759
11760 case ssiDIVINEPROTECTION:
11761 temp_sub->d1 = itype_divineprotection;
11762 break;
11763
11764 case ssiQUIVER:
11765 temp_sub->d1 = itype_quiver;
11766 break;
11767
11768 case ssiBOMBBAG:
11769 temp_sub->d1 = itype_bombbag;
11770 break;
11771
11772 case ssiCBYRNA:
11773 temp_sub->d1 = itype_cbyrna;
11774 break;
11775
11776 case ssiROCS:
11777 temp_sub->d1 = itype_rocs;
11778 break;
11779
11780 case ssiHOVERBOOTS:
11781 temp_sub->d1 = itype_hoverboots;
11782 break;
11783
11784 case ssiSPINSCROLL:
11785 temp_sub->d1 = itype_spinscroll;
11786 break;
11787
11788 case ssiCROSSSCROLL:
11789 temp_sub->d1 = itype_crossscroll;
11790 break;
11791
11792 case ssiQUAKESCROLL:
11793 temp_sub->d1 = itype_quakescroll;
11794 break;
11795
11796 case ssiWHISPRING:
11797 temp_sub->d1 = itype_whispring;
11798 break;
11799
11800 case ssiCHARGERING:
11801 temp_sub->d1 = itype_chargering;
11802 break;
11803
11804 case ssiPERILSCROLL:
11805 temp_sub->d1 = itype_perilscroll;
11806 break;
11807
11808 case ssiWEALTHMEDAL:
11809 temp_sub->d1 = itype_wealthmedal;
11810 break;
11811
11812 case ssiHEARTRING:
11813 temp_sub->d1 = itype_heartring;
11814 break;
11815
11816 case ssiMAGICRING:
11817 temp_sub->d1 = itype_magicring;
11818 break;
11819
11820 case ssiSPINSCROLL2:
11821 temp_sub->d1 = itype_spinscroll2;
11822 break;
11823
11824 case ssiQUAKESCROLL2:
11825 temp_sub->d1 = itype_quakescroll2;
11826 break;
11827
11828 case ssiAGONY:
11829 temp_sub->d1 = itype_agony;
11830 break;
11831
11832 case ssiSTOMPBOOTS:
11833 temp_sub->d1 = itype_stompboots;
11834 break;
11835
11836 case ssiWHIMSICALRING:
11837 temp_sub->d1 = itype_whimsicalring;
11838 break;
11839
11840 case ssiPERILRING:
11841 temp_sub->d1 = itype_perilring;
11842 break;
11843
11844 default:
11845 temp_sub->d1 += itype_custom1 - ssiMAX;
11846 }
11847 }
11848
11849 //fall-through
11850 default:
11851
1/2
✓ Branch 0 taken 43196 times.
✗ Branch 1 not taken.
43196 if(!p_getc(&(temp_sub->dp1),f))
11852 return qe_invalid;
11853
11854 43196 break;
11855 }
11856
11857
2/2
✓ Branch 0 taken 8694 times.
✓ Branch 1 taken 38251 times.
46945 if(s_version < 7)
11858 {
11859
3/3
✓ Branch 0 taken 32094 times.
✓ Branch 1 taken 1389 times.
✓ Branch 2 taken 4768 times.
38251 switch(temp_sub->type)
11860 {
11861 case ssoMAGICGAUGE:
11862 {
11863
2/2
✓ Branch 0 taken 141 times.
✓ Branch 1 taken 1248 times.
1389 if(!temp_sub->d9)
11864 1248 temp_sub->d9 = -1; //-1 now represents 'always'
11865 1389 break;
11866 }
11867 case ssoLIFEGAUGE:
11868 4768 temp_sub->d9 = 0; //Unused, doesn't do anything? Clear it...
11869 4768 break;
11870 }
11871 38251 }
11872
11873
3/3
✓ Branch 0 taken 3497 times.
✓ Branch 1 taken 41854 times.
✓ Branch 2 taken 1594 times.
46945 switch(temp_sub->type)
11874 {
11875 case ssoTEXT:
11876 case ssoTEXTBOX:
11877 case ssoCURRENTITEMTEXT:
11878 case ssoCURRENTITEMCLASSTEXT:
11879
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3497 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3497 if(g->objects[j].dp1 != NULL) delete[](char *)g->objects[j].dp1;
11880
11881 3497 memcpy(&g->objects[j],temp_sub,sizeof(subscreen_object));
11882 3497 g->objects[j].dp1 = new char[temp_size+2];
11883 3497 strcpy((char*)g->objects[j].dp1,tempdp1);
11884 3497 break;
11885
11886 case ssoCOUNTER:
11887
1/2
✓ Branch 0 taken 1594 times.
✗ Branch 1 not taken.
1594 if(s_version<3)
11888 {
11889 temp_sub->d6=(temp_sub->d6?1:0)+(temp_sub->d8?2:0);
11890 temp_sub->d8=0;
11891 }
11892
11893 default:
11894 43448 memcpy(&g->objects[j],temp_sub,sizeof(subscreen_object));
11895 43448 break;
11896 }
11897
11898 46945 g->name[0] = '\0';
11899 46945 strncat(g->name, tempname, 64 - 1);
11900 46945 g->ss_type = temp_ss;
11901 46945 }
11902
11903
2/2
✓ Branch 0 taken 7260319 times.
✓ Branch 1 taken 28544 times.
7288863 for(j=numsub; j<MAXSUBSCREENITEMS; j++)
11904 {
11905 //clear all unused object in this subscreen -DD
11906
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7260319 times.
7260319 switch(g->objects[j].type)
11907 {
11908 case ssoTEXT:
11909 case ssoTEXTBOX:
11910 case ssoCURRENTITEMTEXT:
11911 case ssoCURRENTITEMCLASSTEXT:
11912 if(g->objects[j].dp1 != NULL) delete [](char *)g->objects[j].dp1;
11913
11914 //fall through
11915 default:
11916 7260319 memset(&g->objects[j],0,sizeof(subscreen_object));
11917 7260319 break;
11918 }
11919 7260319 }
11920
11921 28544 return 0;
11922 28544 }
11923
11924 398 int32_t readsubscreens(PACKFILE *f)
11925 {
11926 word s_version;
11927 dword dummy;
11928
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 if(!p_igetw(&s_version,f))
11929 return qe_invalid;
11930 398 FFCore.quest_format[vSubscreen] = s_version;
11931
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!read_deprecated_section_cversion(f))
11932 return qe_invalid;
11933
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_igetl(&dummy,f)) //section size
11934 return qe_invalid;
11935
11936
2/2
✓ Branch 0 taken 223 times.
✓ Branch 1 taken 175 times.
398 if(s_version < 8)
11937 223 return read_old_subscreens(f,s_version);
11938
11939 175 subscreens_active.clear();
11940 175 subscreens_passive.clear();
11941 175 subscreens_overlay.clear();
11942
11943 byte sz;
11944
1/2
✓ Branch 0 taken 175 times.
✗ Branch 1 not taken.
175 if(!p_getc(&sz,f))
11945 return qe_invalid;
11946
2/2
✓ Branch 0 taken 571 times.
✓ Branch 1 taken 175 times.
746 for(byte q = 0; q < sz; ++q)
11947 {
11948 571 ZCSubscreen& tmp = subscreens_active.emplace_back();
11949
1/2
✓ Branch 0 taken 571 times.
✗ Branch 1 not taken.
571 if (auto ret = tmp.read(f, s_version))
11950 return ret;
11951 571 }
11952
1/2
✓ Branch 0 taken 175 times.
✗ Branch 1 not taken.
175 if(!p_getc(&sz,f))
11953 return qe_invalid;
11954
2/2
✓ Branch 0 taken 664 times.
✓ Branch 1 taken 175 times.
839 for(byte q = 0; q < sz; ++q)
11955 {
11956 664 ZCSubscreen& tmp = subscreens_passive.emplace_back();
11957
1/2
✓ Branch 0 taken 664 times.
✗ Branch 1 not taken.
664 if (auto ret = tmp.read(f, s_version))
11958 return ret;
11959 664 }
11960
1/2
✓ Branch 0 taken 175 times.
✗ Branch 1 not taken.
175 if(!p_getc(&sz,f))
11961 return qe_invalid;
11962
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 175 times.
181 for(byte q = 0; q < sz; ++q)
11963 {
11964 6 ZCSubscreen& tmp = subscreens_overlay.emplace_back();
11965
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if (auto ret = tmp.read(f, s_version))
11966 return ret;
11967 6 }
11968 175 return 0;
11969 398 }
11970
11971 void reset_subscreen(subscreen_group *tempss)
11972 {
11973 for(int32_t i=0; i<MAXSUBSCREENITEMS; ++i)
11974 {
11975 switch(tempss->objects[i].type)
11976 {
11977 case ssoTEXT:
11978 case ssoTEXTBOX:
11979 case ssoCURRENTITEMTEXT:
11980 case ssoCURRENTITEMCLASSTEXT:
11981 if(tempss->objects[i].dp1 != NULL) delete [](char *)tempss->objects[i].dp1;
11982
11983 //fall through
11984 default:
11985 memset(&tempss->objects[i],0,sizeof(subscreen_object));
11986 break;
11987 }
11988 }
11989 }
11990
11991 117 void reset_subscreens()
11992 {
11993 117 subscreens_active.clear();
11994 117 subscreens_passive.clear();
11995 117 subscreens_overlay.clear();
11996 117 }
11997
11998 117 int32_t setupsubscreens()
11999 {
12000 117 reset_subscreens();
12001 //return 0;
12002
2/2
✓ Branch 0 taken 117 times.
✓ Branch 1 taken 234 times.
351 for(int q = 0; q < 2; ++q)
12003 {
12004 234 subscreens_active.emplace_back();
12005 234 subscreens_passive.emplace_back();
12006 234 }
12007 117 int32_t tempsubscreen=subscr_mode;
12008
12009
1/2
✓ Branch 0 taken 117 times.
✗ Branch 1 not taken.
117 if(tempsubscreen>=ssdtMAX)
12010 tempsubscreen=0;
12011
12012
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 117 times.
✗ Branch 2 not taken.
117 switch(tempsubscreen)
12013 {
12014 case ssdtOLD:
12015 case ssdtNEWSUBSCR:
12016 case ssdtREV2:
12017 case ssdtBSZELDA:
12018 case ssdtBSZELDAMODIFIED:
12019 case ssdtBSZELDAENHANCED:
12020 case ssdtBSZELDACOMPLETE:
12021 {
12022 117 subscreens_active[0].load_old(default_subscreen_active[tempsubscreen][0]);
12023 117 subscreens_active[0].sub_type=sstACTIVE;
12024 117 subscreens_active[0].name = "Active Subscreen (Triforce)";
12025 117 subscreens_active[1].load_old(default_subscreen_active[tempsubscreen][1]);
12026 117 subscreens_active[1].sub_type=sstACTIVE;
12027 117 subscreens_active[1].name = "Active Subscreen (Dungeon Map)";
12028 117 subscreens_passive[0].load_old(default_subscreen_passive[tempsubscreen][0]);
12029 117 subscreens_passive[0].sub_type=sstPASSIVE;
12030 117 subscreens_passive[0].name = "Passive Subscreen (Magic)";
12031 117 subscreens_passive[1].load_old(default_subscreen_passive[tempsubscreen][1]);
12032 117 subscreens_passive[1].sub_type=sstPASSIVE;
12033 117 subscreens_passive[1].name = "Passive Subscreen (No Magic)";
12034 117 break;
12035 }
12036
12037 case ssdtZ3:
12038 {
12039 subscreens_active[0].load_old(z3_active_a);
12040 subscreens_active[0].sub_type=sstACTIVE;
12041 subscreens_active[1].load_old(z3_active_ab);
12042 subscreens_active[1].sub_type=sstACTIVE;
12043 subscreens_passive[0].load_old(z3_passive_a);
12044 subscreens_passive[0].sub_type=sstPASSIVE;
12045 subscreens_passive[1].load_old(z3_passive_ab);
12046 subscreens_passive[1].sub_type=sstPASSIVE;
12047 break;
12048 }
12049 }
12050 117 subscr_mode = ssdtMAX;
12051 117 return 0;
12052 }
12053
12054 extern std::vector<std::shared_ptr<zasm_script>> zasm_scripts;
12055
12056 extern script_data *ffscripts[NUMSCRIPTFFC];
12057 extern script_data *itemscripts[NUMSCRIPTITEM];
12058 extern script_data *guyscripts[NUMSCRIPTGUYS];
12059 extern script_data *lwpnscripts[NUMSCRIPTWEAPONS];
12060 extern script_data *ewpnscripts[NUMSCRIPTWEAPONS];
12061 extern script_data *globalscripts[NUMSCRIPTGLOBAL];
12062 extern script_data *genericscripts[NUMSCRIPTSGENERIC];
12063 extern script_data *playerscripts[NUMSCRIPTHERO];
12064 extern script_data *screenscripts[NUMSCRIPTSCREEN];
12065 extern script_data *dmapscripts[NUMSCRIPTSDMAP];
12066 extern script_data *itemspritescripts[NUMSCRIPTSITEMSPRITE];
12067 extern script_data *comboscripts[NUMSCRIPTSCOMBODATA];
12068 extern script_data *subscreenscripts[NUMSCRIPTSSUBSCREEN];
12069
12070 static std::vector<const script_data*> read_scripts;
12071
12072 424 static script_data fake_script_data(ScriptType::None, 0);
12073
12074 492 int32_t readffscript(PACKFILE *f, zquestheader *Header)
12075 {
12076 int32_t dummy;
12077 492 word s_version=0, zmeta_version=0;
12078 492 byte numscripts=0;
12079 492 numscripts=numscripts; //to avoid unused variables warnings
12080 int32_t ret;
12081 492 read_scripts.clear();
12082 492 zasm_scripts.clear();
12083
12084 //section version info
12085
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 492 times.
492 if(!p_igetw(&s_version,f))
12086 {
12087 return qe_invalid;
12088 }
12089
12090 492 FFCore.quest_format[vFFScript] = s_version;
12091
12092
1/2
✓ Branch 0 taken 492 times.
✗ Branch 1 not taken.
492 if(!read_deprecated_section_cversion(f))
12093 {
12094 return qe_invalid;
12095 }
12096
12097
2/2
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 192 times.
492 if(s_version >= 18)
12098 {
12099
1/2
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
192 if(!p_igetw(&zmeta_version,f))
12100 {
12101 return qe_invalid;
12102 }
12103 192 }
12104
12105 //section size
12106
1/2
✓ Branch 0 taken 492 times.
✗ Branch 1 not taken.
492 if(!p_igetl(&dummy,f))
12107 {
12108 return qe_invalid;
12109 }
12110
12111
2/2
✓ Branch 0 taken 267 times.
✓ Branch 1 taken 225 times.
492 if ( FFCore.quest_format[vLastCompile] < 13 ) FFCore.quest_format[vLastCompile] = s_version;
12112 492 al_trace("Loaded scripts last compiled in ZScript version: %d\n", (FFCore.quest_format[vLastCompile]));
12113
12114
2/2
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 126 times.
492 if(s_version >= 27)
12115 {
12116 126 ret = read_quest_zasm(f, s_version);
12117
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 if(ret)
12118 return qe_invalid;
12119 126 }
12120
12121 //finally... section data
12122
2/2
✓ Branch 0 taken 203776 times.
✓ Branch 1 taken 412 times.
204188 for(int32_t i = 0; i < ((s_version < 2) ? NUMSCRIPTFFCOLD : NUMSCRIPTFFC); i++)
12123 {
12124 203776 ret = read_one_ffscript(f, Header, i, s_version, ffscripts[i], zmeta_version);
12125
12126
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if (ret)
12127 {
12128 return qe_invalid;
12129 }
12130 203776 }
12131
12132 /* HIGHLY UNORTHODOX UPDATING THING, by Deedee
12133 * This fixes changes to sprite jump values introduced in early 2.55 alphas.
12134 * Zoria didn't bump up the versions as liberally as he should have, but thankfully
12135 * there was a version bump a week before a change that broke stuff.
12136 */
12137
7/8
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 220 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 192 times.
✓ Branch 4 taken 192 times.
✓ Branch 5 taken 192 times.
✓ Branch 6 taken 192 times.
✓ Branch 7 taken 192 times.
412 if(((Header->zelda_version < 0x253)||((Header->zelda_version == 0x253)&&(Header->build<33))||((Header->zelda_version > 0x253) && s_version < 12)))
12138 {
12139 604 set_qr(qr_SPRITE_JUMP_IS_TRUNCATED,1);
12140 604 }
12141
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 206 times.
398 if(s_version < 19)
12142 {
12143 206 set_qr(qr_FLUCTUATING_ENEMY_JUMP,1);
12144 206 }
12145
12146
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 if(s_version > 1)
12147 {
12148
2/2
✓ Branch 0 taken 101888 times.
✓ Branch 1 taken 398 times.
102286 for(int32_t i = 0; i < NUMSCRIPTITEM; i++)
12149 {
12150 101888 ret = read_one_ffscript(f, Header, i, s_version, itemscripts[i], zmeta_version);
12151
12152
1/2
✓ Branch 0 taken 101888 times.
✗ Branch 1 not taken.
101888 if (ret)
12153 {
12154 return qe_invalid;
12155 }
12156 101888 }
12157
12158
2/2
✓ Branch 0 taken 101888 times.
✓ Branch 1 taken 398 times.
102286 for(int32_t i = 0; i < NUMSCRIPTGUYS; i++)
12159 {
12160 101888 ret = read_one_ffscript(f, Header, i, s_version, guyscripts[i], zmeta_version);
12161
12162
1/2
✓ Branch 0 taken 101888 times.
✗ Branch 1 not taken.
101888 if (ret)
12163 {
12164 return qe_invalid;
12165 }
12166 101888 }
12167
12168
2/2
✓ Branch 0 taken 101888 times.
✓ Branch 1 taken 398 times.
102286 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12169 {
12170 101888 ret = read_one_ffscript(f, Header, i, s_version, &fake_script_data, zmeta_version);
12171
12172
1/2
✓ Branch 0 taken 101888 times.
✗ Branch 1 not taken.
101888 if (ret)
12173 {
12174 return qe_invalid;
12175 }
12176 101888 }
12177
12178
2/2
✓ Branch 0 taken 101888 times.
✓ Branch 1 taken 398 times.
102286 for(int32_t i = 0; i < NUMSCRIPTSCREEN; i++)
12179 {
12180 101888 ret = read_one_ffscript(f, Header, i, s_version, screenscripts[i], zmeta_version);
12181
12182
1/2
✓ Branch 0 taken 101888 times.
✗ Branch 1 not taken.
101888 if (ret)
12183 {
12184 return qe_invalid;
12185 }
12186 101888 }
12187
12188
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 206 times.
398 if(s_version > 16)
12189 {
12190
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 192 times.
1728 for(int32_t i = 0; i < NUMSCRIPTGLOBAL; ++i)
12191 {
12192 1536 ret = read_one_ffscript(f, Header, i, s_version, globalscripts[i], zmeta_version);
12193
12194
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if (ret)
12195 {
12196 return qe_invalid;
12197 }
12198 1536 }
12199 192 }
12200
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 206 times.
206 else if(s_version > 13)
12201 {
12202 for(int32_t i = 0; i < NUMSCRIPTGLOBAL255OLD; ++i)
12203 {
12204 ret = read_one_ffscript(f, Header, i, s_version, globalscripts[i], zmeta_version);
12205
12206 if (ret)
12207 {
12208 return qe_invalid;
12209 }
12210 }
12211
12212 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12213 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12214
12215 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONSAVE);
12216 }
12217
1/2
✓ Branch 0 taken 206 times.
✗ Branch 1 not taken.
206 else if(s_version > 4)
12218 {
12219
2/2
✓ Branch 0 taken 824 times.
✓ Branch 1 taken 206 times.
1030 for(int32_t i = 0; i < NUMSCRIPTGLOBAL253; ++i)
12220 {
12221 824 ret = read_one_ffscript(f, Header, i, s_version, globalscripts[i], zmeta_version);
12222
12223
1/2
✓ Branch 0 taken 824 times.
✗ Branch 1 not taken.
824 if (ret)
12224 {
12225 return qe_invalid;
12226 }
12227 824 }
12228
12229
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 206 times.
206 if(globalscripts[GLOBAL_SCRIPT_ONLAUNCH] != NULL)
12230
1/2
✓ Branch 0 taken 206 times.
✗ Branch 1 not taken.
206 delete globalscripts[GLOBAL_SCRIPT_ONLAUNCH];
12231
12232
1/2
✓ Branch 0 taken 206 times.
✗ Branch 1 not taken.
206 globalscripts[GLOBAL_SCRIPT_ONLAUNCH] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONLAUNCH);
12233
12234
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 206 times.
206 if(globalscripts[GLOBAL_SCRIPT_ONCONTGAME] != NULL)
12235
1/2
✓ Branch 0 taken 206 times.
✗ Branch 1 not taken.
206 delete globalscripts[GLOBAL_SCRIPT_ONCONTGAME];
12236
12237
1/2
✓ Branch 0 taken 206 times.
✗ Branch 1 not taken.
206 globalscripts[GLOBAL_SCRIPT_ONCONTGAME] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONCONTGAME);
12238
12239
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 206 times.
206 if(globalscripts[GLOBAL_SCRIPT_F6] != NULL)
12240
1/2
✓ Branch 0 taken 206 times.
✗ Branch 1 not taken.
206 delete globalscripts[GLOBAL_SCRIPT_F6];
12241
12242
1/2
✓ Branch 0 taken 206 times.
✗ Branch 1 not taken.
206 globalscripts[GLOBAL_SCRIPT_F6] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_F6);
12243
12244
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 206 times.
206 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12245
1/2
✓ Branch 0 taken 206 times.
✗ Branch 1 not taken.
206 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12246
12247
1/2
✓ Branch 0 taken 206 times.
✗ Branch 1 not taken.
206 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONSAVE);
12248 206 }
12249 else
12250 {
12251 for(int32_t i = 0; i < NUMSCRIPTGLOBALOLD; i++)
12252 {
12253 ret = read_one_ffscript(f, Header, i, s_version, globalscripts[i], zmeta_version);
12254
12255 if (ret)
12256 {
12257 return qe_invalid;
12258 }
12259 }
12260
12261 if(globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] != NULL)
12262 delete globalscripts[GLOBAL_SCRIPT_ONSAVELOAD];
12263
12264 globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONSAVELOAD);
12265
12266 if(globalscripts[GLOBAL_SCRIPT_ONLAUNCH] != NULL)
12267 delete globalscripts[GLOBAL_SCRIPT_ONLAUNCH];
12268
12269 globalscripts[GLOBAL_SCRIPT_ONLAUNCH] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONLAUNCH);
12270
12271 if(globalscripts[GLOBAL_SCRIPT_ONCONTGAME] != NULL)
12272 delete globalscripts[GLOBAL_SCRIPT_ONCONTGAME];
12273
12274 globalscripts[GLOBAL_SCRIPT_ONCONTGAME] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONCONTGAME);
12275
12276 if(globalscripts[GLOBAL_SCRIPT_F6] != NULL)
12277 delete globalscripts[GLOBAL_SCRIPT_F6];
12278
12279 globalscripts[GLOBAL_SCRIPT_F6] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_F6);
12280
12281 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12282 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12283
12284 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONSAVE);
12285 }
12286
12287
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 206 times.
398 if(s_version > 10) //expanded the number of Hero scripts to 5.
12288 {
12289
2/2
✓ Branch 0 taken 960 times.
✓ Branch 1 taken 192 times.
1152 for(int32_t i = 0; i < NUMSCRIPTHERO; i++)
12290 {
12291 960 ret = read_one_ffscript(f, Header, i, s_version, playerscripts[i], zmeta_version);
12292
12293
1/2
✓ Branch 0 taken 960 times.
✗ Branch 1 not taken.
960 if (ret)
12294 {
12295 return qe_invalid;
12296 }
12297 960 }
12298 192 }
12299 else
12300 {
12301
2/2
✓ Branch 0 taken 618 times.
✓ Branch 1 taken 206 times.
824 for(int32_t i = 0; i < NUMSCRIPTHEROOLD; i++)
12302 {
12303 618 ret = read_one_ffscript(f, Header, i, s_version, playerscripts[i], zmeta_version);
12304
12305
1/2
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
618 if (ret)
12306 {
12307 return qe_invalid;
12308 }
12309 618 }
12310
1/2
✓ Branch 0 taken 206 times.
✗ Branch 1 not taken.
206 if(playerscripts[3] != NULL)
12311
1/2
✓ Branch 0 taken 206 times.
✗ Branch 1 not taken.
206 delete playerscripts[3];
12312
12313
1/2
✓ Branch 0 taken 206 times.
✗ Branch 1 not taken.
206 playerscripts[3] = new script_data(ScriptType::Hero, 3);
12314
12315
1/2
✓ Branch 0 taken 206 times.
✗ Branch 1 not taken.
206 if(playerscripts[4] != NULL)
12316
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 206 times.
206 delete playerscripts[4];
12317
12318
1/2
✓ Branch 0 taken 206 times.
✗ Branch 1 not taken.
206 playerscripts[4] = new script_data(ScriptType::Hero, 4);
12319 }
12320
3/4
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 206 times.
✓ Branch 2 taken 192 times.
✗ Branch 3 not taken.
398 if(s_version > 8 && s_version < 10)
12321 {
12322
12323 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12324 {
12325 ret = read_one_ffscript(f, Header, i, s_version, ewpnscripts[i], zmeta_version);
12326
12327 if (ret)
12328 {
12329 return qe_invalid;
12330 }
12331 }
12332 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
12333 {
12334 ret = read_one_ffscript(f, Header, i, s_version, dmapscripts[i], zmeta_version);
12335
12336 if (ret)
12337 {
12338 return qe_invalid;
12339 }
12340 }
12341
12342 }
12343
2/2
✓ Branch 0 taken 206 times.
✓ Branch 1 taken 192 times.
398 if(s_version >= 10)
12344 {
12345
2/2
✓ Branch 0 taken 49152 times.
✓ Branch 1 taken 192 times.
49344 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12346 {
12347 49152 ret = read_one_ffscript(f, Header, i, s_version, lwpnscripts[i], zmeta_version);
12348
12349
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if (ret)
12350 {
12351 return qe_invalid;
12352 }
12353 49152 }
12354
2/2
✓ Branch 0 taken 49152 times.
✓ Branch 1 taken 192 times.
49344 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12355 {
12356 49152 ret = read_one_ffscript(f, Header, i, s_version, ewpnscripts[i], zmeta_version);
12357
12358
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if (ret)
12359 {
12360 return qe_invalid;
12361 }
12362 49152 }
12363
2/2
✓ Branch 0 taken 49152 times.
✓ Branch 1 taken 192 times.
49344 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
12364 {
12365 49152 ret = read_one_ffscript(f, Header, i, s_version, dmapscripts[i], zmeta_version);
12366
12367
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if (ret)
12368 {
12369 return qe_invalid;
12370 }
12371 49152 }
12372
12373 192 }
12374
2/2
✓ Branch 0 taken 206 times.
✓ Branch 1 taken 192 times.
398 if(s_version >=12)
12375 {
12376
2/2
✓ Branch 0 taken 49152 times.
✓ Branch 1 taken 192 times.
49344 for(int32_t i = 0; i < NUMSCRIPTSITEMSPRITE; i++)
12377 {
12378 49152 ret = read_one_ffscript(f, Header, i, s_version, itemspritescripts[i], zmeta_version);
12379
12380
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if (ret)
12381 {
12382 return qe_invalid;
12383 }
12384 49152 }
12385 192 }
12386
2/2
✓ Branch 0 taken 206 times.
✓ Branch 1 taken 192 times.
398 if(s_version >=15)
12387 {
12388
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 192 times.
98496 for(int32_t i = 0; i < NUMSCRIPTSCOMBODATA; i++)
12389 {
12390 98304 ret = read_one_ffscript(f, Header, i, s_version, comboscripts[i], zmeta_version);
12391
12392
1/2
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
98304 if (ret)
12393 {
12394 return qe_invalid;
12395 }
12396 98304 }
12397 192 }
12398
2/2
✓ Branch 0 taken 206 times.
✓ Branch 1 taken 192 times.
398 if(s_version >19)
12399 {
12400 192 word numgenscripts = NUMSCRIPTSGENERIC;
12401
1/2
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
192 if(!p_igetw(&numgenscripts,f))
12402 {
12403 return qe_invalid;
12404 }
12405
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 192 times.
98496 for(int32_t i = 0; i < numgenscripts; i++)
12406 {
12407 98304 ret = read_one_ffscript(f, Header, i, s_version, genericscripts[i], zmeta_version);
12408
12409
1/2
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
98304 if (ret)
12410 {
12411 return qe_invalid;
12412 }
12413 98304 }
12414 192 }
12415
2/2
✓ Branch 0 taken 223 times.
✓ Branch 1 taken 175 times.
398 if(s_version >21)
12416 {
12417 175 word numsubscripts = NUMSCRIPTSSUBSCREEN;
12418
1/2
✓ Branch 0 taken 175 times.
✗ Branch 1 not taken.
175 if(!p_igetw(&numsubscripts,f))
12419 {
12420 return qe_invalid;
12421 }
12422
2/2
✓ Branch 0 taken 44800 times.
✓ Branch 1 taken 175 times.
44975 for(int32_t i = 0; i < numsubscripts; i++)
12423 {
12424 44800 ret = read_one_ffscript(f, Header, i, s_version, subscreenscripts[i], zmeta_version);
12425
12426
1/2
✓ Branch 0 taken 44800 times.
✗ Branch 1 not taken.
44800 if (ret)
12427 {
12428 return qe_invalid;
12429 }
12430 44800 }
12431 175 }
12432 398 }
12433
12434
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 if(s_version > 2)
12435 {
12436 int32_t bufsize;
12437 398 p_igetl(&bufsize, f);
12438
2/4
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 398 times.
398 if (bufsize < 0 || bufsize > 1024*1024*10)
12439 {
12440 // God help anyone storing more than 10MB of code in the script buffer.
12441 return qe_invalid;
12442 }
12443 398 char * buf = new char[bufsize+1];
12444 398 pfread(buf, bufsize, f);
12445 398 buf[bufsize]=0;
12446
12447
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 zScript = string(buf);
12448
12449
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 delete[] buf;
12450 word numffcbindings;
12451 398 p_igetw(&numffcbindings, f);
12452
12453
2/2
✓ Branch 0 taken 10950 times.
✓ Branch 1 taken 398 times.
11348 for(int32_t i=0; i<numffcbindings; i++)
12454 {
12455 word id;
12456 10950 p_igetw(&id, f);
12457 10950 p_igetl(&bufsize, f);
12458
2/4
✓ Branch 0 taken 10950 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 10950 times.
10950 if (bufsize < 0 || bufsize > 1024)
12459 return qe_invalid;
12460 10950 buf = new char[bufsize+1];
12461 10950 pfread(buf, bufsize, f);
12462 10950 buf[bufsize]=0;
12463
12464 //fix for buggy older saved quests -DD
12465
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10950 times.
10950 if(id < NUMSCRIPTFFC-1)
12466 10950 ffcmap[id].scriptname = buf;
12467
12468
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10950 times.
10950 delete[] buf;
12469 10950 }
12470
12471 word numglobalbindings;
12472 398 p_igetw(&numglobalbindings, f);
12473
12474
2/2
✓ Branch 0 taken 1599 times.
✓ Branch 1 taken 398 times.
1997 for(int32_t i=0; i<numglobalbindings; i++)
12475 {
12476 word id;
12477 1599 p_igetw(&id, f);
12478 1599 p_igetl(&bufsize, f);
12479
2/4
✓ Branch 0 taken 1599 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1599 times.
✗ Branch 3 not taken.
1599 if (bufsize < 0 || bufsize > 1024)
12480 return qe_invalid;
12481 1599 buf = new char[bufsize+1];
12482 1599 pfread(buf, bufsize, f);
12483 1599 buf[bufsize]=0;
12484
12485 // id in principle should be valid, since slot assignment cannot assign a global script to a bogus slot.
12486 // However, because of a corruption bug, some 2.50.x quests contain bogus entries in the global bindings table.
12487 // Ignore these. -DD
12488
2/2
✓ Branch 0 taken 558 times.
✓ Branch 1 taken 1041 times.
1599 if (id < NUMSCRIPTGLOBAL)
12489 {
12490 //Disable old '~Continue's, they'd wreak havoc. Bit messy, apologies ~Joe
12491
1/2
✓ Branch 0 taken 1041 times.
✗ Branch 1 not taken.
1041 if(strcmp(buf,"~Continue") == 0)
12492 {
12493 globalmap[id].scriptname = "";
12494
12495 if(globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] != NULL)
12496 globalscripts[GLOBAL_SCRIPT_ONSAVELOAD]->disable();
12497 }
12498 else
12499 {
12500 1041 globalmap[id].scriptname = buf;
12501 }
12502 1041 }
12503
12504
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1599 times.
1599 delete[] buf;
12505 1599 }
12506
12507
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 if(s_version > 3)
12508 {
12509 word numitembindings;
12510 398 p_igetw(&numitembindings, f);
12511
12512
2/2
✓ Branch 0 taken 1308 times.
✓ Branch 1 taken 398 times.
1706 for(int32_t i=0; i<numitembindings; i++)
12513 {
12514 word id;
12515 1308 p_igetw(&id, f);
12516 1308 p_igetl(&bufsize, f);
12517
2/4
✓ Branch 0 taken 1308 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1308 times.
1308 if (bufsize < 0 || bufsize > 1024)
12518 return qe_invalid;
12519 1308 buf = new char[bufsize+1];
12520 1308 pfread(buf, bufsize, f);
12521 1308 buf[bufsize]=0;
12522
12523 //fix this too
12524
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1308 times.
1308 if(id <NUMSCRIPTITEM-1)
12525 1308 itemmap[id].scriptname = buf;
12526
12527
1/2
✓ Branch 0 taken 1308 times.
✗ Branch 1 not taken.
1308 delete[] buf;
12528 1308 }
12529 398 }
12530 //(v9+)
12531
2/2
✓ Branch 0 taken 206 times.
✓ Branch 1 taken 192 times.
398 if(s_version > 8)
12532 {
12533 //npc scripts
12534 word numnpcbindings;
12535 192 p_igetw(&numnpcbindings, f);
12536
12537
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 192 times.
224 for(int32_t i=0; i<numnpcbindings; i++)
12538 {
12539 word id;
12540 32 p_igetw(&id, f);
12541 32 p_igetl(&bufsize, f);
12542
2/4
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 32 times.
✗ Branch 3 not taken.
32 if (bufsize < 0 || bufsize > 1024)
12543 return qe_invalid;
12544 32 buf = new char[bufsize+1];
12545 32 pfread(buf, bufsize, f);
12546 32 buf[bufsize]=0;
12547
12548 //fix this too
12549
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if(id <NUMSCRIPTGUYS-1)
12550 32 npcmap[id].scriptname = buf;
12551
12552
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 delete[] buf;
12553 32 }
12554 //lweapon
12555 word numlwpnbindings;
12556 192 p_igetw(&numlwpnbindings, f);
12557
12558
2/2
✓ Branch 0 taken 333 times.
✓ Branch 1 taken 192 times.
525 for(int32_t i=0; i<numlwpnbindings; i++)
12559 {
12560 word id;
12561 333 p_igetw(&id, f);
12562 333 p_igetl(&bufsize, f);
12563
2/4
✓ Branch 0 taken 333 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 333 times.
333 if (bufsize < 0 || bufsize > 1024)
12564 return qe_invalid;
12565 333 buf = new char[bufsize+1];
12566 333 pfread(buf, bufsize, f);
12567 333 buf[bufsize]=0;
12568
12569 //fix this too
12570
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 333 times.
333 if(id <NUMSCRIPTWEAPONS-1)
12571 333 lwpnmap[id].scriptname = buf;
12572
12573
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 333 times.
333 delete[] buf;
12574 333 }
12575 //eweapon
12576 word numewpnbindings;
12577 192 p_igetw(&numewpnbindings, f);
12578
12579
2/2
✓ Branch 0 taken 297 times.
✓ Branch 1 taken 192 times.
489 for(int32_t i=0; i<numewpnbindings; i++)
12580 {
12581 word id;
12582 297 p_igetw(&id, f);
12583 297 p_igetl(&bufsize, f);
12584
2/4
✓ Branch 0 taken 297 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 297 times.
✗ Branch 3 not taken.
297 if (bufsize < 0 || bufsize > 1024)
12585 return qe_invalid;
12586 297 buf = new char[bufsize+1];
12587 297 pfread(buf, bufsize, f);
12588 297 buf[bufsize]=0;
12589
12590 //fix this too
12591
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 297 times.
297 if(id <NUMSCRIPTWEAPONS-1)
12592 297 ewpnmap[id].scriptname = buf;
12593
12594
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 297 times.
297 delete[] buf;
12595 297 }
12596 //hero
12597 word numherobindings;
12598 192 p_igetw(&numherobindings, f);
12599
12600
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 192 times.
215 for(int32_t i=0; i<numherobindings; i++)
12601 {
12602 word id;
12603 23 p_igetw(&id, f);
12604 23 p_igetl(&bufsize, f);
12605
2/4
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 23 times.
23 if (bufsize < 0 || bufsize > 1024)
12606 return qe_invalid;
12607 23 buf = new char[bufsize+1];
12608 23 pfread(buf, bufsize, f);
12609 23 buf[bufsize]=0;
12610
12611 //fix this too
12612
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
23 if(id <NUMSCRIPTHERO-1)
12613 23 playermap[id].scriptname = buf;
12614
12615
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 delete[] buf;
12616 23 }
12617 //dmaps
12618 word numdmapbindings;
12619 192 p_igetw(&numdmapbindings, f);
12620
12621
2/2
✓ Branch 0 taken 441 times.
✓ Branch 1 taken 192 times.
633 for(int32_t i=0; i<numdmapbindings; i++)
12622 {
12623 word id;
12624 441 p_igetw(&id, f);
12625 441 p_igetl(&bufsize, f);
12626
2/4
✓ Branch 0 taken 441 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 441 times.
441 if (bufsize < 0 || bufsize > 1024)
12627 return qe_invalid;
12628 441 buf = new char[bufsize+1];
12629 441 pfread(buf, bufsize, f);
12630 441 buf[bufsize]=0;
12631
12632 //fix this too
12633
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 441 times.
441 if(id <NUMSCRIPTSDMAP-1)
12634 441 dmapmap[id].scriptname = buf;
12635
12636
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 441 times.
441 delete[] buf;
12637 441 }
12638 //screen
12639 word numscreenbindings;
12640 192 p_igetw(&numscreenbindings, f);
12641
12642
2/2
✓ Branch 0 taken 415 times.
✓ Branch 1 taken 192 times.
607 for(int32_t i=0; i<numscreenbindings; i++)
12643 {
12644 word id;
12645 415 p_igetw(&id, f);
12646 415 p_igetl(&bufsize, f);
12647
2/4
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 415 times.
✗ Branch 3 not taken.
415 if (bufsize < 0 || bufsize > 1024)
12648 return qe_invalid;
12649 415 buf = new char[bufsize+1];
12650 415 pfread(buf, bufsize, f);
12651 415 buf[bufsize]=0;
12652
12653 //fix this too
12654
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 415 times.
415 if(id <NUMSCRIPTSDMAP-1)
12655 415 screenmap[id].scriptname = buf;
12656
12657
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 415 times.
415 delete[] buf;
12658 415 }
12659 192 }
12660
2/2
✓ Branch 0 taken 206 times.
✓ Branch 1 taken 192 times.
398 if(s_version > 11)
12661 {
12662 word numspritebindings;
12663 192 p_igetw(&numspritebindings, f);
12664
12665
2/2
✓ Branch 0 taken 49 times.
✓ Branch 1 taken 192 times.
241 for(int32_t i=0; i<numspritebindings; i++)
12666 {
12667 word id;
12668 49 p_igetw(&id, f);
12669 49 p_igetl(&bufsize, f);
12670
2/4
✓ Branch 0 taken 49 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 49 times.
49 if (bufsize < 0 || bufsize > 1024)
12671 return qe_invalid;
12672 49 buf = new char[bufsize+1];
12673 49 pfread(buf, bufsize, f);
12674 49 buf[bufsize]=0;
12675
12676 //fix this too
12677
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 49 times.
49 if(id <NUMSCRIPTSDMAP-1)
12678 49 itemspritemap[id].scriptname = buf;
12679
12680
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 49 times.
49 delete[] buf;
12681 49 }
12682 192 }
12683
2/2
✓ Branch 0 taken 206 times.
✓ Branch 1 taken 192 times.
398 if(s_version >= 15)
12684 {
12685 word numcombobindings;
12686 192 p_igetw(&numcombobindings, f);
12687
12688
2/2
✓ Branch 0 taken 157 times.
✓ Branch 1 taken 192 times.
349 for(int32_t i=0; i<numcombobindings; i++)
12689 {
12690 word id;
12691 157 p_igetw(&id, f);
12692 157 p_igetl(&bufsize, f);
12693
2/4
✓ Branch 0 taken 157 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 157 times.
✗ Branch 3 not taken.
157 if (bufsize < 0 || bufsize > 1024)
12694 return qe_invalid;
12695 157 buf = new char[bufsize+1];
12696 157 pfread(buf, bufsize, f);
12697 157 buf[bufsize]=0;
12698
12699 //fix this too
12700
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 157 times.
157 if(id <NUMSCRIPTSCOMBODATA-1)
12701 157 comboscriptmap[id].scriptname = buf;
12702
12703
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 157 times.
157 delete[] buf;
12704 157 }
12705 192 }
12706
2/2
✓ Branch 0 taken 206 times.
✓ Branch 1 taken 192 times.
398 if(s_version > 19)
12707 {
12708 word numgenericbindings;
12709 192 p_igetw(&numgenericbindings, f);
12710
12711
2/2
✓ Branch 0 taken 1969 times.
✓ Branch 1 taken 192 times.
2161 for(int32_t i=0; i<numgenericbindings; i++)
12712 {
12713 word id;
12714 1969 p_igetw(&id, f);
12715 1969 p_igetl(&bufsize, f);
12716
2/4
✓ Branch 0 taken 1969 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1969 times.
✗ Branch 3 not taken.
1969 if (bufsize < 0 || bufsize > 1024)
12717 return qe_invalid;
12718 1969 buf = new char[bufsize+1];
12719 1969 pfread(buf, bufsize, f);
12720 1969 buf[bufsize]=0;
12721
12722 //fix this too
12723
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1969 times.
1969 if(id <NUMSCRIPTSGENERIC-1)
12724 1969 genericmap[id].scriptname = buf;
12725
12726
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1969 times.
1969 delete[] buf;
12727 1969 }
12728 192 }
12729
2/2
✓ Branch 0 taken 223 times.
✓ Branch 1 taken 175 times.
398 if(s_version > 21)
12730 {
12731 word numsubscreenbindings;
12732 175 p_igetw(&numsubscreenbindings, f);
12733
12734
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 175 times.
183 for(int32_t i=0; i<numsubscreenbindings; i++)
12735 {
12736 word id;
12737 8 p_igetw(&id, f);
12738 8 p_igetl(&bufsize, f);
12739
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 if (bufsize < 0 || bufsize > 1024)
12740 return qe_invalid;
12741 8 buf = new char[bufsize+1];
12742 8 pfread(buf, bufsize, f);
12743 8 buf[bufsize]=0;
12744
12745 //fix this too
12746
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(id <NUMSCRIPTSSUBSCREEN-1)
12747 8 subscreenmap[id].scriptname = buf;
12748
12749
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 delete[] buf;
12750 8 }
12751 175 }
12752 398 }
12753
12754 // Set ZScriptVersion to the value encoded in the script's meta.ffscript_v.
12755 // This is only updated when the scripts have been recompiled.
12756 // They should all match each other.
12757 398 std::optional<word> zscript_version;
12758
2/2
✓ Branch 0 taken 206 times.
✓ Branch 1 taken 192 times.
398 if (s_version >= 16)
12759 {
12760
2/2
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 7333 times.
7523 for (auto script : read_scripts)
12761 {
12762
2/2
✓ Branch 0 taken 7331 times.
✓ Branch 1 taken 2 times.
7333 if (script->meta.ffscript_v == 0)
12763 {
12764 // These scripts were saved in a version prior to this field being set.
12765 // See https://discord.com/channels/876899628556091432/1368485306394738718
12766 2 zscript_version = 16;
12767 2 break;
12768 }
12769
1/2
✓ Branch 0 taken 7331 times.
✗ Branch 1 not taken.
7331 if (script->meta.ffscript_v > s_version)
12770 break;
12771
12772
2/2
✓ Branch 0 taken 7159 times.
✓ Branch 1 taken 172 times.
7331 if (!zscript_version.has_value())
12773 {
12774 172 zscript_version = script->meta.ffscript_v;
12775 172 continue;
12776 }
12777
12778
1/2
✓ Branch 0 taken 7159 times.
✗ Branch 1 not taken.
7159 if (zscript_version.value() != script->meta.ffscript_v)
12779 {
12780 zscript_version.reset();
12781 break;
12782 }
12783 }
12784
12785
2/2
✓ Branch 0 taken 174 times.
✓ Branch 1 taken 18 times.
192 if (!zscript_version.has_value())
12786 18 al_trace("WARNING: Setting zscript version to section version as fallback.\n");
12787 192 }
12788 398 setZScriptVersion(zscript_version.value_or(s_version));
12789 398 read_scripts.clear();
12790
12791 398 return 0;
12792 398 }
12793
12794 void(*reset_scripts_hook)();
12795
12796 480 void reset_scripts()
12797 {
12798 // We can't modify the script data while jit threads are possibly compiling them.
12799
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 469 times.
480 if (reset_scripts_hook)
12800 469 reset_scripts_hook();
12801
12802
2/2
✓ Branch 0 taken 245760 times.
✓ Branch 1 taken 480 times.
246240 for(int32_t i=0; i<NUMSCRIPTSGENERIC; i++)
12803 {
12804
1/2
✓ Branch 0 taken 245760 times.
✗ Branch 1 not taken.
245760 if (genericscripts[i]!=NULL) genericscripts[i]->disable();
12805 else genericscripts[i] = new script_data({ScriptType::Generic, i});
12806 245760 }
12807
12808
2/2
✓ Branch 0 taken 245760 times.
✓ Branch 1 taken 480 times.
246240 for(int32_t i=0; i<NUMSCRIPTFFC; i++)
12809 {
12810
1/2
✓ Branch 0 taken 245760 times.
✗ Branch 1 not taken.
245760 if (ffscripts[i])
12811 245760 ffscripts[i]->disable();
12812 else
12813 ffscripts[i] = new script_data(ScriptType::FFC, i);
12814 245760 }
12815
12816
2/2
✓ Branch 0 taken 122880 times.
✓ Branch 1 taken 480 times.
123360 for(int32_t i=0; i<NUMSCRIPTITEM; i++)
12817 {
12818
1/2
✓ Branch 0 taken 122880 times.
✗ Branch 1 not taken.
122880 if (itemscripts[i])
12819 122880 itemscripts[i]->disable();
12820 else
12821 itemscripts[i] = new script_data(ScriptType::Item, i);
12822 122880 }
12823
12824
2/2
✓ Branch 0 taken 122880 times.
✓ Branch 1 taken 480 times.
123360 for(int32_t i=0; i<NUMSCRIPTGUYS; i++)
12825 {
12826
1/2
✓ Branch 0 taken 122880 times.
✗ Branch 1 not taken.
122880 if (guyscripts[i])
12827 122880 guyscripts[i]->disable();
12828 else
12829 guyscripts[i] = new script_data(ScriptType::NPC, i);
12830 122880 }
12831
12832
2/2
✓ Branch 0 taken 122880 times.
✓ Branch 1 taken 480 times.
123360 for(int32_t i=0; i<NUMSCRIPTSCREEN; i++)
12833 {
12834
1/2
✓ Branch 0 taken 122880 times.
✗ Branch 1 not taken.
122880 if (screenscripts[i])
12835 122880 screenscripts[i]->disable();
12836 else
12837 screenscripts[i] = new script_data(ScriptType::Screen, i);
12838 122880 }
12839
12840
2/2
✓ Branch 0 taken 3840 times.
✓ Branch 1 taken 480 times.
4320 for(int32_t i=0; i<NUMSCRIPTGLOBAL; i++)
12841 {
12842
1/2
✓ Branch 0 taken 3840 times.
✗ Branch 1 not taken.
3840 if (globalscripts[i])
12843 3840 globalscripts[i]->disable();
12844 else
12845 globalscripts[i] = new script_data(ScriptType::Global, i);
12846 3840 }
12847
12848
2/2
✓ Branch 0 taken 2400 times.
✓ Branch 1 taken 480 times.
2880 for(int32_t i=0; i<NUMSCRIPTHERO; i++)
12849 {
12850
1/2
✓ Branch 0 taken 2400 times.
✗ Branch 1 not taken.
2400 if (playerscripts[i])
12851 2400 playerscripts[i]->disable();
12852 else
12853 playerscripts[i] = new script_data(ScriptType::Hero, i);
12854 2400 }
12855
12856
2/2
✓ Branch 0 taken 122880 times.
✓ Branch 1 taken 480 times.
123360 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
12857 {
12858
1/2
✓ Branch 0 taken 122880 times.
✗ Branch 1 not taken.
122880 if (lwpnscripts[i])
12859 122880 lwpnscripts[i]->disable();
12860 else
12861 lwpnscripts[i] = new script_data(ScriptType::Lwpn, i);
12862 122880 }
12863
2/2
✓ Branch 0 taken 122880 times.
✓ Branch 1 taken 480 times.
123360 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
12864 {
12865
1/2
✓ Branch 0 taken 122880 times.
✗ Branch 1 not taken.
122880 if (ewpnscripts[i])
12866 122880 ewpnscripts[i]->disable();
12867 else
12868 ewpnscripts[i] = new script_data(ScriptType::Ewpn, i);
12869 122880 }
12870
12871
2/2
✓ Branch 0 taken 122880 times.
✓ Branch 1 taken 480 times.
123360 for(int32_t i=0; i<NUMSCRIPTSDMAP; i++)
12872 {
12873
1/2
✓ Branch 0 taken 122880 times.
✗ Branch 1 not taken.
122880 if (dmapscripts[i])
12874 122880 dmapscripts[i]->disable();
12875 else
12876 dmapscripts[i] = new script_data(ScriptType::DMap, i);
12877 122880 }
12878
2/2
✓ Branch 0 taken 122880 times.
✓ Branch 1 taken 480 times.
123360 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE; i++)
12879 {
12880
1/2
✓ Branch 0 taken 122880 times.
✗ Branch 1 not taken.
122880 if (itemspritescripts[i])
12881 122880 itemspritescripts[i]->disable();
12882 else
12883 itemspritescripts[i] = new script_data(ScriptType::ItemSprite, i);
12884 122880 }
12885
2/2
✓ Branch 0 taken 245760 times.
✓ Branch 1 taken 480 times.
246240 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA; i++)
12886 {
12887
1/2
✓ Branch 0 taken 245760 times.
✗ Branch 1 not taken.
245760 if (comboscripts[i])
12888 245760 comboscripts[i]->disable();
12889 else
12890 comboscripts[i] = new script_data(ScriptType::Combo, i);
12891 245760 }
12892
2/2
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 122880 times.
123360 for(int32_t i=0; i<NUMSCRIPTSSUBSCREEN; i++)
12893 {
12894
1/2
✓ Branch 0 taken 122880 times.
✗ Branch 1 not taken.
122880 if (subscreenscripts[i])
12895 122880 subscreenscripts[i]->disable();
12896 else
12897 subscreenscripts[i] = new script_data(ScriptType::EngineSubscreen, i);
12898 122880 }
12899 480 }
12900
12901 // 3.0+ calls this.
12902 126 int32_t read_quest_zasm(PACKFILE *f, word s_version)
12903 {
12904 int32_t num_commands;
12905
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 if(!p_igetl(&num_commands,f))
12906 return qe_invalid;
12907 #ifdef ZC_FUZZ
12908 const int32_t command_limit = 300000;
12909 #else
12910 126 const int32_t command_limit = 25000000;
12911 #endif
12912
2/4
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 126 times.
126 if (num_commands < 0 || num_commands > command_limit)
12913 return qe_invalid;
12914
12915 126 std::vector<ffscript> zasm;
12916
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 zasm.reserve(num_commands);
12917
2/2
✓ Branch 0 taken 3255862 times.
✓ Branch 1 taken 126 times.
3255988 for(int32_t j=0; j<num_commands; j++)
12918 {
12919
1/2
✓ Branch 0 taken 3255862 times.
✗ Branch 1 not taken.
3255862 ffscript temp_script;
12920
2/4
✓ Branch 0 taken 3255862 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3255862 times.
✗ Branch 3 not taken.
3255862 if(!p_igetw(&(temp_script.command),f))
12921 return qe_invalid;
12922
12923
2/4
✓ Branch 0 taken 3255862 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3255862 times.
✗ Branch 3 not taken.
3255862 if(!p_igetl(&(temp_script.arg1),f))
12924 return qe_invalid;
12925
12926
2/4
✓ Branch 0 taken 3255862 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3255862 times.
✗ Branch 3 not taken.
3255862 if(!p_igetl(&(temp_script.arg2),f))
12927 return qe_invalid;
12928
12929
2/4
✓ Branch 0 taken 3255862 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3255862 times.
✗ Branch 3 not taken.
3255862 if(!p_igetl(&(temp_script.arg3),f))
12930 return qe_invalid;
12931
12932 3255862 uint32_t sz = 0;
12933
2/4
✓ Branch 0 taken 3255862 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3255862 times.
✗ Branch 3 not taken.
3255862 if(!p_igetl(&sz,f))
12934 return qe_invalid;
12935
2/2
✓ Branch 0 taken 39569 times.
✓ Branch 1 taken 3216293 times.
3255862 if(sz) //string found
12936 {
12937
1/2
✓ Branch 0 taken 39569 times.
✗ Branch 1 not taken.
39569 temp_script.strptr = new std::string();
12938 char dummy;
12939
2/2
✓ Branch 0 taken 719999 times.
✓ Branch 1 taken 39569 times.
759568 for(size_t q = 0; q < sz; ++q)
12940 {
12941
2/4
✓ Branch 0 taken 719999 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 719999 times.
✗ Branch 3 not taken.
719999 if(!p_getc(&dummy,f))
12942 return qe_invalid;
12943
1/2
✓ Branch 0 taken 719999 times.
✗ Branch 1 not taken.
719999 temp_script.strptr->push_back(dummy);
12944 719999 }
12945 39569 }
12946
2/4
✓ Branch 0 taken 3255862 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3255862 times.
✗ Branch 3 not taken.
3255862 if(!p_igetl(&sz,f))
12947 return qe_invalid;
12948
2/2
✓ Branch 0 taken 5646 times.
✓ Branch 1 taken 3250216 times.
3255862 if(sz) //vector found
12949 {
12950
1/2
✓ Branch 0 taken 5646 times.
✗ Branch 1 not taken.
5646 temp_script.vecptr = new std::vector<int32_t>();
12951 int32_t dummy;
12952
2/2
✓ Branch 0 taken 16957 times.
✓ Branch 1 taken 5646 times.
22603 for(size_t q = 0; q < sz; ++q)
12953 {
12954
2/4
✓ Branch 0 taken 16957 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16957 times.
✗ Branch 3 not taken.
16957 if(!p_igetl(&dummy,f))
12955 return qe_invalid;
12956
1/2
✓ Branch 0 taken 16957 times.
✗ Branch 1 not taken.
16957 temp_script.vecptr->push_back(dummy);
12957 16957 }
12958 5646 }
12959
1/2
✓ Branch 0 taken 3255862 times.
✗ Branch 1 not taken.
3255862 zasm.emplace_back(std::move(temp_script));
12960
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3255862 times.
3255862 }
12961
12962
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 assert(zasm_scripts.empty());
12963 126 zasm_script_id id = zasm_scripts.size();
12964
2/4
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 126 times.
126 zasm_scripts.emplace_back(std::make_shared<zasm_script>(id, "@single", std::move(zasm)));
12965
12966 126 return 0;
12967 126 }
12968
12969 1053282 int32_t read_one_ffscript(PACKFILE *f, zquestheader *, int32_t script_index, word s_version, script_data *script, word zmeta_version)
12970 {
12971 ASSERT(script);
12972
2/2
✓ Branch 0 taken 567804 times.
✓ Branch 1 taken 485478 times.
1053282 if(s_version < 27)
12973 567804 return read_old_ffscript(f, script_index, s_version, script, zmeta_version);
12974
12975 char exists;
12976
1/2
✓ Branch 0 taken 485478 times.
✗ Branch 1 not taken.
485478 if (!p_getc(&exists, f))
12977 return qe_invalid;
12978
2/2
✓ Branch 0 taken 4289 times.
✓ Branch 1 taken 481189 times.
485478 if (!exists)
12979 {
12980 481189 script->disable();
12981 481189 return 0;
12982 }
12983
12984 //Read meta
12985 {
12986 4289 zasm_meta temp_meta;
12987
12988
2/4
✓ Branch 0 taken 4289 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4289 times.
✗ Branch 3 not taken.
4289 if(!p_igetw(&(temp_meta.zasm_v),f))
12989 return qe_invalid;
12990
2/4
✓ Branch 0 taken 4289 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4289 times.
✗ Branch 3 not taken.
4289 if(!p_igetw(&(temp_meta.meta_v),f))
12991 return qe_invalid;
12992
2/4
✓ Branch 0 taken 4289 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4289 times.
✗ Branch 3 not taken.
4289 if(!p_igetw(&(temp_meta.ffscript_v),f))
12993 return qe_invalid;
12994
2/4
✓ Branch 0 taken 4289 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4289 times.
✗ Branch 3 not taken.
4289 if(!p_getc(&(temp_meta.script_type),f))
12995 return qe_invalid;
12996
12997
2/2
✓ Branch 0 taken 34312 times.
✓ Branch 1 taken 4289 times.
38601 for(int32_t q = 0; q < 8; ++q)
12998 {
12999
2/4
✓ Branch 0 taken 34312 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 34312 times.
✗ Branch 3 not taken.
34312 if(!p_getcstr(&temp_meta.run_idens[q],f))
13000 return qe_invalid;
13001 34312 }
13002
13003
2/2
✓ Branch 0 taken 4289 times.
✓ Branch 1 taken 34312 times.
38601 for(int32_t q = 0; q < 8; ++q)
13004
2/4
✓ Branch 0 taken 34312 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 34312 times.
✗ Branch 3 not taken.
34312 if(!p_getc(&(temp_meta.run_types[q]),f))
13005 return qe_invalid;
13006
13007
2/4
✓ Branch 0 taken 4289 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4289 times.
✗ Branch 3 not taken.
4289 if(!p_getc(&(temp_meta.flags),f))
13008 return qe_invalid;
13009
13010
2/4
✓ Branch 0 taken 4289 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4289 times.
✗ Branch 3 not taken.
4289 if(!p_igetw(&(temp_meta.compiler_v1),f))
13011 return qe_invalid;
13012
2/4
✓ Branch 0 taken 4289 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4289 times.
✗ Branch 3 not taken.
4289 if(!p_igetw(&(temp_meta.compiler_v2),f))
13013 return qe_invalid;
13014
2/4
✓ Branch 0 taken 4289 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4289 times.
✗ Branch 3 not taken.
4289 if(!p_igetw(&(temp_meta.compiler_v3),f))
13015 return qe_invalid;
13016
2/4
✓ Branch 0 taken 4289 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4289 times.
✗ Branch 3 not taken.
4289 if(!p_igetw(&(temp_meta.compiler_v4),f))
13017 return qe_invalid;
13018
13019
2/4
✓ Branch 0 taken 4289 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4289 times.
✗ Branch 3 not taken.
4289 if(!p_getcstr(&temp_meta.script_name,f))
13020 return qe_invalid;
13021
2/4
✓ Branch 0 taken 4289 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4289 times.
✗ Branch 3 not taken.
4289 if(!p_getcstr(&temp_meta.author,f))
13022 return qe_invalid;
13023 4289 auto num_meta_attrib = 10;
13024
2/2
✓ Branch 0 taken 42890 times.
✓ Branch 1 taken 4289 times.
47179 for(auto q = 0; q < num_meta_attrib; ++q)
13025 {
13026
2/4
✓ Branch 0 taken 42890 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 42890 times.
✗ Branch 3 not taken.
42890 if(!p_getcstr(&temp_meta.attributes[q],f))
13027 return qe_invalid;
13028
2/4
✓ Branch 0 taken 42890 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 42890 times.
✗ Branch 3 not taken.
42890 if(!p_getwstr(&temp_meta.attributes_help[q],f))
13029 return qe_invalid;
13030 42890 }
13031
2/2
✓ Branch 0 taken 34312 times.
✓ Branch 1 taken 4289 times.
38601 for(auto q = 0; q < 8; ++q)
13032 {
13033
2/4
✓ Branch 0 taken 34312 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 34312 times.
✗ Branch 3 not taken.
34312 if(!p_getcstr(&temp_meta.attribytes[q],f))
13034 return qe_invalid;
13035
2/4
✓ Branch 0 taken 34312 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 34312 times.
✗ Branch 3 not taken.
34312 if(!p_getwstr(&temp_meta.attribytes_help[q],f))
13036 return qe_invalid;
13037 34312 }
13038
2/2
✓ Branch 0 taken 34312 times.
✓ Branch 1 taken 4289 times.
38601 for(auto q = 0; q < 8; ++q)
13039 {
13040
2/4
✓ Branch 0 taken 34312 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 34312 times.
✗ Branch 3 not taken.
34312 if(!p_getcstr(&temp_meta.attrishorts[q],f))
13041 return qe_invalid;
13042
2/4
✓ Branch 0 taken 34312 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 34312 times.
✗ Branch 3 not taken.
34312 if(!p_getwstr(&temp_meta.attrishorts_help[q],f))
13043 return qe_invalid;
13044 34312 }
13045
2/2
✓ Branch 0 taken 68624 times.
✓ Branch 1 taken 4289 times.
72913 for(auto q = 0; q < 16; ++q)
13046 {
13047
2/4
✓ Branch 0 taken 68624 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68624 times.
✗ Branch 3 not taken.
68624 if(!p_getcstr(&temp_meta.usrflags[q],f))
13048 return qe_invalid;
13049
2/4
✓ Branch 0 taken 68624 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68624 times.
✗ Branch 3 not taken.
68624 if(!p_getwstr(&temp_meta.usrflags_help[q],f))
13050 return qe_invalid;
13051 68624 }
13052
2/2
✓ Branch 0 taken 34312 times.
✓ Branch 1 taken 4289 times.
38601 for(auto q = 0; q < 8; ++q)
13053 {
13054
2/4
✓ Branch 0 taken 34312 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 34312 times.
✗ Branch 3 not taken.
34312 if(!p_getcstr(&temp_meta.initd[q],f))
13055 return qe_invalid;
13056
2/4
✓ Branch 0 taken 34312 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 34312 times.
✗ Branch 3 not taken.
34312 if(!p_getwstr(&temp_meta.initd_help[q],f))
13057 return qe_invalid;
13058 34312 }
13059
2/2
✓ Branch 0 taken 4289 times.
✓ Branch 1 taken 34312 times.
38601 for(auto q = 0; q < 8; ++q)
13060 {
13061
2/4
✓ Branch 0 taken 34312 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 34312 times.
✗ Branch 3 not taken.
34312 if(!p_getc(&temp_meta.initd_type[q],f))
13062 return qe_invalid;
13063 34312 }
13064
13065
1/2
✓ Branch 0 taken 4289 times.
✗ Branch 1 not taken.
4289 script->meta = temp_meta;
13066
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 4289 times.
4289 }
13067
1/2
✓ Branch 0 taken 4289 times.
✗ Branch 1 not taken.
4289 if(!p_igetl(&script->pc, f))
13068 return qe_invalid;
13069
1/2
✓ Branch 0 taken 4289 times.
✗ Branch 1 not taken.
4289 if(!p_igetl(&script->end_pc, f))
13070 return qe_invalid;
13071
13072
1/2
✓ Branch 0 taken 4289 times.
✗ Branch 1 not taken.
4289 if (script == &fake_script_data)
13073 return 0;
13074
13075
1/2
✓ Branch 0 taken 4289 times.
✗ Branch 1 not taken.
4289 assert(zasm_scripts.size() == 1);
13076 4289 auto& zs = zasm_scripts[0];
13077 4289 script->zasm_script = zs;
13078
13079
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4289 times.
4289 if (script->valid())
13080 {
13081 4289 zs->script_datas.push_back(script);
13082 4289 read_scripts.push_back(script);
13083 4289 }
13084
13085 4289 return 0;
13086 1053282 }
13087
13088 567804 int32_t read_old_ffscript(PACKFILE *f, int32_t script_index, word s_version, script_data *script, word zmeta_version)
13089 {
13090 567804 char b33[34] = {0};
13091 567804 b33[33] = 0;
13092 567804 int32_t num_commands=1000;
13093
13094
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 567804 times.
567804 if(s_version>=2)
13095 {
13096
1/2
✓ Branch 0 taken 567804 times.
✗ Branch 1 not taken.
567804 if(!p_igetl(&num_commands,f))
13097 {
13098 return qe_invalid;
13099 }
13100 567804 }
13101
13102 #ifdef ZC_FUZZ
13103 const int32_t command_limit = 300000;
13104 #else
13105 567804 const int32_t command_limit = 10000000;
13106 #endif
13107
2/4
✓ Branch 0 taken 567804 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 567804 times.
567804 if (num_commands < 0 || num_commands > command_limit)
13108 {
13109 return qe_invalid;
13110 }
13111
13112 567804 std::vector<ffscript> zasm;
13113
1/2
✓ Branch 0 taken 567804 times.
✗ Branch 1 not taken.
567804 zasm.reserve(num_commands);
13114
13115
2/2
✓ Branch 0 taken 249946 times.
✓ Branch 1 taken 317858 times.
567804 if(s_version >= 16)
13116 {
13117
1/2
✓ Branch 0 taken 249946 times.
✗ Branch 1 not taken.
249946 zasm_meta temp_meta;
13118
13119
2/4
✓ Branch 0 taken 249946 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249946 times.
✗ Branch 3 not taken.
249946 if(!p_igetw(&(temp_meta.zasm_v),f))
13120 {
13121 return qe_invalid;
13122 }
13123
13124
2/4
✓ Branch 0 taken 249946 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249946 times.
✗ Branch 3 not taken.
249946 if(!p_igetw(&(temp_meta.meta_v),f))
13125 {
13126 return qe_invalid;
13127 }
13128
13129
2/4
✓ Branch 0 taken 249946 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249946 times.
✗ Branch 3 not taken.
249946 if(!p_igetw(&(temp_meta.ffscript_v),f))
13130 {
13131 return qe_invalid;
13132 }
13133
13134
2/4
✓ Branch 0 taken 249946 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249946 times.
✗ Branch 3 not taken.
249946 if(!p_getc(&(temp_meta.script_type),f))
13135 {
13136 return qe_invalid;
13137 }
13138
13139
2/2
✓ Branch 0 taken 1999568 times.
✓ Branch 1 taken 249946 times.
2249514 for(int32_t q = 0; q < 8; ++q)
13140 {
13141
2/2
✓ Branch 0 taken 143880 times.
✓ Branch 1 taken 1855688 times.
1999568 if(zmeta_version < 3)
13142 {
13143
2/2
✓ Branch 0 taken 143880 times.
✓ Branch 1 taken 4748040 times.
4891920 for(int32_t c = 0; c < 33; ++c)
13144 {
13145
2/4
✓ Branch 0 taken 4748040 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4748040 times.
✗ Branch 3 not taken.
4748040 if(!p_getc(&(b33[c]),f))
13146 {
13147 return qe_invalid;
13148 }
13149 4748040 }
13150
1/2
✓ Branch 0 taken 143880 times.
✗ Branch 1 not taken.
143880 temp_meta.run_idens[q].assign(b33);
13151 143880 }
13152 else
13153 {
13154
2/4
✓ Branch 0 taken 1855688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1855688 times.
✗ Branch 3 not taken.
1855688 if(!p_getcstr(&temp_meta.run_idens[q],f))
13155 {
13156 return qe_invalid;
13157 }
13158 }
13159 1999568 }
13160
13161
2/2
✓ Branch 0 taken 249946 times.
✓ Branch 1 taken 1999568 times.
2249514 for(int32_t q = 0; q < 8; ++q)
13162 {
13163
2/4
✓ Branch 0 taken 1999568 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1999568 times.
✗ Branch 3 not taken.
1999568 if(!p_getc(&(temp_meta.run_types[q]),f))
13164 {
13165 return qe_invalid;
13166 }
13167 1999568 }
13168
13169
2/4
✓ Branch 0 taken 249946 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249946 times.
✗ Branch 3 not taken.
249946 if(!p_getc(&(temp_meta.flags),f))
13170 {
13171 return qe_invalid;
13172 }
13173
13174
2/4
✓ Branch 0 taken 249946 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249946 times.
✗ Branch 3 not taken.
249946 if(!p_igetw(&(temp_meta.compiler_v1),f))
13175 {
13176 return qe_invalid;
13177 }
13178
13179
2/4
✓ Branch 0 taken 249946 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249946 times.
✗ Branch 3 not taken.
249946 if(!p_igetw(&(temp_meta.compiler_v2),f))
13180 {
13181 return qe_invalid;
13182 }
13183
13184
2/4
✓ Branch 0 taken 249946 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249946 times.
✗ Branch 3 not taken.
249946 if(!p_igetw(&(temp_meta.compiler_v3),f))
13185 {
13186 return qe_invalid;
13187 }
13188
13189
2/4
✓ Branch 0 taken 249946 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249946 times.
✗ Branch 3 not taken.
249946 if(!p_igetw(&(temp_meta.compiler_v4),f))
13190 {
13191 return qe_invalid;
13192 }
13193
13194
2/2
✓ Branch 0 taken 17985 times.
✓ Branch 1 taken 231961 times.
249946 if(zmeta_version == 2)
13195 {
13196
2/2
✓ Branch 0 taken 17985 times.
✓ Branch 1 taken 593505 times.
611490 for(int32_t c = 0; c < 33; ++c)
13197 {
13198
2/4
✓ Branch 0 taken 593505 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 593505 times.
✗ Branch 3 not taken.
593505 if(!p_getc(&b33[c],f))
13199 {
13200 return qe_invalid;
13201 }
13202 593505 }
13203
1/2
✓ Branch 0 taken 17985 times.
✗ Branch 1 not taken.
17985 temp_meta.script_name.assign(b33);
13204
13205
2/2
✓ Branch 0 taken 17985 times.
✓ Branch 1 taken 593505 times.
611490 for(int32_t c = 0; c < 33; ++c)
13206 {
13207
2/4
✓ Branch 0 taken 593505 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 593505 times.
✗ Branch 3 not taken.
593505 if(!p_getc(&b33[c],f))
13208 {
13209 return qe_invalid;
13210 }
13211 593505 }
13212
1/2
✓ Branch 0 taken 17985 times.
✗ Branch 1 not taken.
17985 temp_meta.author.assign(b33);
13213 17985 }
13214
1/2
✓ Branch 0 taken 231961 times.
✗ Branch 1 not taken.
231961 else if(zmeta_version > 2)
13215 {
13216
2/4
✓ Branch 0 taken 231961 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 231961 times.
✗ Branch 3 not taken.
231961 if(!p_getcstr(&temp_meta.script_name,f))
13217 return qe_invalid;
13218
2/4
✓ Branch 0 taken 231961 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 231961 times.
✗ Branch 3 not taken.
231961 if(!p_getcstr(&temp_meta.author,f))
13219 return qe_invalid;
13220 231961 auto num_meta_attrib = (zmeta_version < 5 ? 4 : 10);
13221
2/2
✓ Branch 0 taken 2319610 times.
✓ Branch 1 taken 231961 times.
2551571 for(auto q = 0; q < num_meta_attrib; ++q)
13222 {
13223
2/4
✓ Branch 0 taken 2319610 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2319610 times.
✗ Branch 3 not taken.
2319610 if(!p_getcstr(&temp_meta.attributes[q],f))
13224 return qe_invalid;
13225
2/4
✓ Branch 0 taken 2319610 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2319610 times.
✗ Branch 3 not taken.
2319610 if(!p_getwstr(&temp_meta.attributes_help[q],f))
13226 return qe_invalid;
13227 2319610 }
13228
2/2
✓ Branch 0 taken 1855688 times.
✓ Branch 1 taken 231961 times.
2087649 for(auto q = 0; q < 8; ++q)
13229 {
13230
2/4
✓ Branch 0 taken 1855688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1855688 times.
✗ Branch 3 not taken.
1855688 if(!p_getcstr(&temp_meta.attribytes[q],f))
13231 return qe_invalid;
13232
2/4
✓ Branch 0 taken 1855688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1855688 times.
✗ Branch 3 not taken.
1855688 if(!p_getwstr(&temp_meta.attribytes_help[q],f))
13233 return qe_invalid;
13234 1855688 }
13235
2/2
✓ Branch 0 taken 1855688 times.
✓ Branch 1 taken 231961 times.
2087649 for(auto q = 0; q < 8; ++q)
13236 {
13237
2/4
✓ Branch 0 taken 1855688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1855688 times.
✗ Branch 3 not taken.
1855688 if(!p_getcstr(&temp_meta.attrishorts[q],f))
13238 return qe_invalid;
13239
2/4
✓ Branch 0 taken 1855688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1855688 times.
✗ Branch 3 not taken.
1855688 if(!p_getwstr(&temp_meta.attrishorts_help[q],f))
13240 return qe_invalid;
13241 1855688 }
13242
2/2
✓ Branch 0 taken 3711376 times.
✓ Branch 1 taken 231961 times.
3943337 for(auto q = 0; q < 16; ++q)
13243 {
13244
2/4
✓ Branch 0 taken 3711376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3711376 times.
✗ Branch 3 not taken.
3711376 if(!p_getcstr(&temp_meta.usrflags[q],f))
13245 return qe_invalid;
13246
2/4
✓ Branch 0 taken 3711376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3711376 times.
✗ Branch 3 not taken.
3711376 if(!p_getwstr(&temp_meta.usrflags_help[q],f))
13247 return qe_invalid;
13248 3711376 }
13249 231961 }
13250
2/2
✓ Branch 0 taken 231961 times.
✓ Branch 1 taken 17985 times.
249946 if(zmeta_version > 3)
13251 {
13252
2/2
✓ Branch 0 taken 1855688 times.
✓ Branch 1 taken 231961 times.
2087649 for(auto q = 0; q < 8; ++q)
13253 {
13254
2/4
✓ Branch 0 taken 1855688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1855688 times.
✗ Branch 3 not taken.
1855688 if(!p_getcstr(&temp_meta.initd[q],f))
13255 return qe_invalid;
13256
2/4
✓ Branch 0 taken 1855688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1855688 times.
✗ Branch 3 not taken.
1855688 if(!p_getwstr(&temp_meta.initd_help[q],f))
13257 return qe_invalid;
13258 1855688 }
13259
2/2
✓ Branch 0 taken 1855688 times.
✓ Branch 1 taken 231961 times.
2087649 for(auto q = 0; q < 8; ++q)
13260 {
13261
2/4
✓ Branch 0 taken 1855688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1855688 times.
✗ Branch 3 not taken.
1855688 if(!p_getc(&temp_meta.initd_type[q],f))
13262 return qe_invalid;
13263 1855688 }
13264 231961 }
13265 else
13266 {
13267
2/2
✓ Branch 0 taken 143880 times.
✓ Branch 1 taken 17985 times.
161865 for(auto q = 0; q < 8; ++q)
13268 {
13269
1/2
✓ Branch 0 taken 143880 times.
✗ Branch 1 not taken.
143880 temp_meta.initd[q] = temp_meta.run_idens[q];
13270 143880 }
13271 }
13272
13273
1/2
✓ Branch 0 taken 249946 times.
✗ Branch 1 not taken.
249946 script->meta = temp_meta;
13274
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 249946 times.
✓ Branch 2 taken 317858 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 317858 times.
✗ Branch 5 not taken.
567804 } else script->meta = {};
13275
13276
2/2
✓ Branch 0 taken 74674 times.
✓ Branch 1 taken 107367287 times.
107441961 for(int32_t j=0; j<num_commands; j++)
13277 {
13278
1/2
✓ Branch 0 taken 107367287 times.
✗ Branch 1 not taken.
107367287 auto& sc = zasm.emplace_back();
13279
2/4
✓ Branch 0 taken 107367287 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 107367287 times.
✗ Branch 3 not taken.
107367287 if(!p_igetw(&sc.command,f))
13280 {
13281 return qe_invalid;
13282 }
13283
13284
2/2
✓ Branch 0 taken 106874157 times.
✓ Branch 1 taken 493130 times.
107367287 if(sc.command == 0xFFFF)
13285 493130 break;
13286 else
13287 {
13288
2/4
✓ Branch 0 taken 106874157 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 106874157 times.
✗ Branch 3 not taken.
106874157 if(!p_igetl(&sc.arg1,f))
13289 {
13290 return qe_invalid;
13291 }
13292
13293
2/4
✓ Branch 0 taken 106874157 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 106874157 times.
✗ Branch 3 not taken.
106874157 if(!p_igetl(&sc.arg2,f))
13294 {
13295 return qe_invalid;
13296 }
13297
13298
2/2
✓ Branch 0 taken 1047747 times.
✓ Branch 1 taken 105826410 times.
106874157 if(s_version >= 24)
13299
2/4
✓ Branch 0 taken 1047747 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1047747 times.
✗ Branch 3 not taken.
1047747 if(!p_igetl(&sc.arg3,f))
13300 return qe_invalid;
13301
13302
2/2
✓ Branch 0 taken 8222037 times.
✓ Branch 1 taken 98652120 times.
106874157 if(s_version >= 21)
13303 {
13304 8222037 uint32_t sz = 0;
13305
2/4
✓ Branch 0 taken 8222037 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8222037 times.
✗ Branch 3 not taken.
8222037 if(!p_igetl(&sz,f))
13306 {
13307 return qe_invalid;
13308 }
13309
2/2
✓ Branch 0 taken 19400 times.
✓ Branch 1 taken 8202637 times.
8222037 if(sz) //string found
13310 {
13311
1/2
✓ Branch 0 taken 19400 times.
✗ Branch 1 not taken.
19400 sc.strptr = new std::string();
13312 char dummy;
13313
2/2
✓ Branch 0 taken 1165008 times.
✓ Branch 1 taken 19400 times.
1184408 for(size_t q = 0; q < sz; ++q)
13314 {
13315
2/4
✓ Branch 0 taken 1165008 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1165008 times.
✗ Branch 3 not taken.
1165008 if(!p_getc(&dummy,f))
13316 {
13317 return qe_invalid;
13318 }
13319
1/2
✓ Branch 0 taken 1165008 times.
✗ Branch 1 not taken.
1165008 sc.strptr->push_back(dummy);
13320 1165008 }
13321 19400 }
13322
2/4
✓ Branch 0 taken 8222037 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8222037 times.
✗ Branch 3 not taken.
8222037 if(!p_igetl(&sz,f))
13323 {
13324 return qe_invalid;
13325 }
13326
2/2
✓ Branch 0 taken 933 times.
✓ Branch 1 taken 8221104 times.
8222037 if(sz) //vector found
13327 {
13328
1/2
✓ Branch 0 taken 933 times.
✗ Branch 1 not taken.
933 sc.vecptr = new std::vector<int32_t>();
13329 int32_t dummy;
13330
2/2
✓ Branch 0 taken 11526 times.
✓ Branch 1 taken 933 times.
12459 for(size_t q = 0; q < sz; ++q)
13331 {
13332
2/4
✓ Branch 0 taken 11526 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11526 times.
✗ Branch 3 not taken.
11526 if(!p_igetl(&dummy,f))
13333 {
13334 return qe_invalid;
13335 }
13336
1/2
✓ Branch 0 taken 11526 times.
✗ Branch 1 not taken.
11526 sc.vecptr->push_back(dummy);
13337 11526 }
13338 933 }
13339 8222037 }
13340 }
13341 106874157 }
13342
13343
2/2
✓ Branch 0 taken 498172 times.
✓ Branch 1 taken 69632 times.
567804 if (script == &fake_script_data)
13344 69632 return 0;
13345
13346 // If the first command is unknown, invalidate the whole thing.
13347 // Saw this for https://www.purezc.net/index.php?page=quests&id=411 hero script 0
13348
5/6
✓ Branch 0 taken 428874 times.
✓ Branch 1 taken 69298 times.
✓ Branch 2 taken 416689 times.
✓ Branch 3 taken 12185 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 416689 times.
498172 if (!zasm.empty() && zasm[0].command >= NUMCOMMANDS && zasm[0].command != 0xFFFF)
13349 {
13350 al_trace("Warning: found script with bad instruction, disabling script: %s %d\n", ScriptTypeToString(script->id.type), script->id.index);
13351 zasm.clear();
13352 }
13353
13354 498172 zasm_script_id id = zasm_scripts.size();
13355
3/6
✓ Branch 0 taken 498172 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 498172 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 498172 times.
✗ Branch 5 not taken.
498172 auto& zs = zasm_scripts.emplace_back(std::make_shared<zasm_script>(id, script->name(), std::move(zasm)));
13356 498172 script->zasm_script = zs;
13357 498172 script->pc = 0;
13358 498172 script->end_pc = zs->size;
13359
3/4
✓ Branch 0 taken 498172 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12185 times.
✓ Branch 3 taken 485987 times.
498172 if (script->valid())
13360 {
13361
1/2
✓ Branch 0 taken 12185 times.
✗ Branch 1 not taken.
12185 zs->script_datas.push_back(script);
13362
1/2
✓ Branch 0 taken 12185 times.
✗ Branch 1 not taken.
12185 read_scripts.push_back(script);
13363 12185 }
13364
13365 498172 return 0;
13366 567804 }
13367
13368 extern SAMPLE customsfxdata[WAV_COUNT];
13369 extern uint8_t customsfxflag[WAV_COUNT>>3];
13370 extern int32_t sfxdat;
13371 extern DATAFILE *sfxdata;
13372 const char *old_sfx_string[Z35] =
13373 {
13374 "Arrow", "Sword beam", "Bomb blast", "Boomerang", "Subscreen cursor",
13375 "Shield is hit", "Item chime", "Roar (Dodongo, Gohma)", "Shutter", "Enemy dies",
13376 "Enemy is hit", "Low hearts warning", "Fire", "Ganon's fanfare", "Boss is hit", "Hammer",
13377 "Hookshot", "Message", "Hero is hit", "Item fanfare", "Bomb placed", "Item pickup",
13378 "Refill", "Roar (Aquamentus, Gleeok, Ganon)", "Item pickup 2", "Ocean ambience",
13379 "Secret chime", "Hero dies", "Stairs", "Sword", "Roar (Manhandla, Digdogger, Patra)",
13380 "Wand magic", "Whistle", "Zelda's fanfare", "Charging weapon", "Charging weapon 2",
13381 "Divine Fire", "Enemy falls from ceiling", "Divine Escape", "Fireball", "Tall Grass slashed",
13382 "Pound pounded", "Hover Boots", "Ice magic", "Jump", "Lens of Truth off", "Lens of Truth on",
13383 "Divine Protection shield", "Divine Protection 2", "Push block", "Rock", "Spell rocket down",
13384 "Spell rocket up", "Sword spin attack", "Splash", "Summon magic", "Sword tapping",
13385 "Sword tapping (secret)", "Whistle whirlwind", "Cane of Byrna orbit"
13386 };
13387 char *sfx_string[WAV_COUNT];
13388
13389 398 int32_t readsfx(PACKFILE *f, zquestheader *Header)
13390 {
13391 //these are here to bypass compiler warnings about unused arguments
13392 398 Header=Header;
13393
13394 int32_t dummy;
13395 398 word s_version=0;
13396 //int32_t ret;
13397 398 SAMPLE temp_sample = {};
13398 398 temp_sample.loop_start=0;
13399 398 temp_sample.loop_end=0;
13400 398 temp_sample.param=0;
13401
13402 //section version info
13403
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 if(!p_igetw(&s_version,f))
13404 {
13405 return qe_invalid;
13406 }
13407
13408 398 FFCore.quest_format[vSFX] = s_version;
13409
13410
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!read_deprecated_section_cversion(f))
13411 {
13412 return qe_invalid;
13413 }
13414
13415 //section size
13416
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_igetl(&dummy,f))
13417 {
13418 return qe_invalid;
13419 }
13420
13421 /* HIGHLY UNORTHODOX UPDATING THING, by L
13422 * This fixes quests made before revision 411 (such as the 'Lost Isle Build'),
13423 * where the meaning of GOTOLESS changed. It also coincided with V_SFX
13424 * changing from 1 to 2.
13425 */
13426
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(s_version < 2)
13427 set_qr(qr_GOTOLESSNOTEQUAL,1);
13428
13429 /* End highly unorthodox updating thing */
13430
13431 398 int32_t wavcount = WAV_COUNT;
13432
13433
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(s_version < 6)
13434 wavcount = 128;
13435
13436 uint8_t tempflag[WAV_COUNT>>3];
13437
13438
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 if(s_version < 4)
13439 {
13440 memset(tempflag, 0xFF, WAV_COUNT>>3);
13441 }
13442 else
13443 {
13444
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(s_version < 6)
13445 memset(tempflag, 0, WAV_COUNT>>3);
13446
13447
2/2
✓ Branch 0 taken 12736 times.
✓ Branch 1 taken 398 times.
13134 for(int32_t i=0; i<(wavcount>>3); i++)
13448 {
13449 12736 p_getc(&tempflag[i], f);
13450 12736 }
13451
13452 }
13453
13454
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(s_version>4)
13455 {
13456
2/2
✓ Branch 0 taken 101490 times.
✓ Branch 1 taken 398 times.
101888 for(int32_t i=1; i<WAV_COUNT; i++)
13457 {
13458 101490 sprintf(sfx_string[i],"s%03d",i);
13459
13460
2/2
✓ Branch 0 taken 77610 times.
✓ Branch 1 taken 23880 times.
101490 if((i<Z35))
13461 23880 strcpy(sfx_string[i], old_sfx_string[i-1]);
13462
13463
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101490 times.
101490 if(i>=wavcount)
13464 continue;
13465
2/2
✓ Branch 0 taken 20578 times.
✓ Branch 1 taken 80912 times.
101490 if(get_bit(tempflag, i-1))
13466 {
13467 char tempname[36];
13468
13469
1/2
✓ Branch 0 taken 20578 times.
✗ Branch 1 not taken.
20578 if(!pfread(tempname, 36, f))
13470 {
13471 return qe_invalid;
13472 }
13473
13474 20578 sfx_string[i][0] = '\0';
13475 20578 strncat(sfx_string[i], tempname, 36 - 1);
13476 20578 }
13477 else
13478 {
13479 80912 sprintf(sfx_string[i],"s%03d",i);
13480
13481
2/2
✓ Branch 0 taken 70950 times.
✓ Branch 1 taken 9962 times.
80912 if(i<Z35)
13482 9962 strcpy(sfx_string[i], old_sfx_string[i-1]);
13483 80912 sfx_string[i][35] = 0; //Force NULL Termination
13484 }
13485 101490 }
13486 398 }
13487 else
13488 {
13489 for(int32_t i=1; i<WAV_COUNT; i++)
13490 {
13491 sprintf(sfx_string[i],"s%03d",i);
13492
13493 if(i<Z35)
13494 strcpy(sfx_string[i], old_sfx_string[i-1]);
13495 }
13496 }
13497
13498 //finally... section data
13499
2/2
✓ Branch 0 taken 101490 times.
✓ Branch 1 taken 398 times.
101888 for(int32_t i=1; i<wavcount; i++)
13500 {
13501
2/2
✓ Branch 0 taken 20578 times.
✓ Branch 1 taken 80912 times.
101490 if(get_bit(tempflag, i-1))
13502 {
13503
13504
1/2
✓ Branch 0 taken 20578 times.
✗ Branch 1 not taken.
20578 if(!p_igetl(&dummy,f))
13505 {
13506 return qe_invalid;
13507 }
13508
13509 20578 (temp_sample.bits) = dummy;
13510
13511
1/2
✓ Branch 0 taken 20578 times.
✗ Branch 1 not taken.
20578 if(!p_igetl(&dummy,f))
13512 {
13513 return qe_invalid;
13514 }
13515
13516 20578 (temp_sample.stereo) = dummy;
13517
13518
1/2
✓ Branch 0 taken 20578 times.
✗ Branch 1 not taken.
20578 if(!p_igetl(&dummy,f))
13519 {
13520 return qe_invalid;
13521 }
13522
13523 20578 (temp_sample.freq) = dummy;
13524
13525
1/2
✓ Branch 0 taken 20578 times.
✗ Branch 1 not taken.
20578 if(!p_igetl(&dummy,f))
13526 {
13527 return qe_invalid;
13528 }
13529
13530 20578 (temp_sample.priority) = dummy;
13531
13532
1/2
✓ Branch 0 taken 20578 times.
✗ Branch 1 not taken.
20578 if(!p_igetl(&(temp_sample.len),f))
13533 {
13534 return qe_invalid;
13535 }
13536
13537
1/2
✓ Branch 0 taken 20578 times.
✗ Branch 1 not taken.
20578 if(!p_igetl(&(temp_sample.loop_start),f))
13538 {
13539 return qe_invalid;
13540 }
13541
13542
1/2
✓ Branch 0 taken 20578 times.
✗ Branch 1 not taken.
20578 if(!p_igetl(&(temp_sample.loop_end),f))
13543 {
13544 return qe_invalid;
13545 }
13546
13547
1/2
✓ Branch 0 taken 20578 times.
✗ Branch 1 not taken.
20578 if(!p_igetl(&(temp_sample.param),f))
13548 {
13549 return qe_invalid;
13550 }
13551
13552 20578 auto len = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13553 #ifdef ZC_FUZZ
13554 const int32_t sfx_limit = 100000;
13555 if (len < 0 || len > sfx_limit)
13556 {
13557 return qe_invalid;
13558 }
13559 #endif
13560 20578 temp_sample.data = calloc(len,1);
13561
13562
1/2
✓ Branch 0 taken 20578 times.
✗ Branch 1 not taken.
20578 if(s_version < 3)
13563 len = (temp_sample.bits==8?1:2)*temp_sample.len;
13564
13565 //old-style, non-portable loading (Bad Allegro! Bad!!) -DD
13566
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20578 times.
20578 if(s_version < 2)
13567 {
13568 if(!pfread(temp_sample.data, len,f))
13569 {
13570 return qe_invalid;
13571 }
13572 }
13573 else
13574 {
13575 //re-endianfy the data
13576 20578 int32_t wordstoread = len / sizeof(word);
13577
13578
2/2
✓ Branch 0 taken 569512748 times.
✓ Branch 1 taken 20578 times.
569533326 for(int32_t j=0; j<wordstoread; j++)
13579 {
13580 word temp;
13581
13582
1/2
✓ Branch 0 taken 569512748 times.
✗ Branch 1 not taken.
569512748 if(!p_igetw(&temp, f))
13583 {
13584 return qe_invalid;
13585 }
13586
13587 569512748 ((word *)temp_sample.data)[j] = temp;
13588 569512748 }
13589 }
13590 20578 }
13591
2/2
✓ Branch 0 taken 9962 times.
✓ Branch 1 taken 70950 times.
80912 else if(i < Z35)
13592 {
13593 9962 SAMPLE* datsamp = (SAMPLE*)(sfxdata[i].dat);
13594 9962 memcpy(&temp_sample, datsamp, sizeof(SAMPLE));
13595 9962 set_bit(tempflag, i-1, 1);
13596 9962 int32_t len = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13597 9962 temp_sample.data = calloc(len,1);
13598 9962 memcpy(temp_sample.data, datsamp->data, len);
13599 9962 }
13600 70950 else continue;
13601
13602
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30540 times.
30540 if(customsfxdata[i].data!=NULL)
13603 {
13604 // delete [] customsfxdata[i].data;
13605 30540 free(customsfxdata[i].data);
13606 30540 }
13607
13608 // customsfxdata[i].data = new byte[(temp_sample.bits==8?1:2)*temp_sample.len];
13609 30540 int32_t len2 = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13610 30540 customsfxdata[i].data = calloc(len2,1);
13611 30540 customsfxdata[i].bits = temp_sample.bits;
13612 30540 customsfxdata[i].stereo = temp_sample.stereo;
13613 30540 customsfxdata[i].freq = temp_sample.freq;
13614 30540 customsfxdata[i].priority = temp_sample.priority;
13615 30540 customsfxdata[i].len = temp_sample.len;
13616 30540 customsfxdata[i].loop_start = temp_sample.loop_start;
13617 30540 customsfxdata[i].loop_end = temp_sample.loop_end;
13618 30540 customsfxdata[i].param = temp_sample.param;
13619 30540 int32_t cpylen = len2;
13620
13621
1/2
✓ Branch 0 taken 30540 times.
✗ Branch 1 not taken.
30540 if(s_version<3)
13622 {
13623 cpylen = (temp_sample.bits==8?1:2)*temp_sample.len;
13624 al_trace("WARNING: Quest SFX %d is in stereo, and may be corrupt.\n",i);
13625 }
13626
13627 30540 memcpy(customsfxdata[i].data,temp_sample.data,cpylen);
13628
13629 30540 free(temp_sample.data);
13630 30540 }
13631
13632 398 memcpy(customsfxflag, tempflag, WAV_COUNT>>3);
13633
13634 398 sfxdat=0;
13635 398 return 0;
13636 398 }
13637
13638 480 void setupsfx()
13639 {
13640
2/2
✓ Branch 0 taken 122400 times.
✓ Branch 1 taken 480 times.
122880 for(int32_t i=1; i<WAV_COUNT; i++)
13641 {
13642 122400 sprintf(sfx_string[i],"s%03d",i);
13643
13644
2/2
✓ Branch 0 taken 93600 times.
✓ Branch 1 taken 28800 times.
122400 if(i<Z35)
13645 {
13646 28800 strcpy(sfx_string[i], old_sfx_string[i-1]);
13647 28800 }
13648
13649 122400 memset(customsfxflag, 0, WAV_COUNT>>3);
13650
13651 122400 int32_t j=i;
13652
13653
2/2
✓ Branch 0 taken 29280 times.
✓ Branch 1 taken 93120 times.
122400 if(i>Z35)
13654 {
13655 93120 i=Z35;
13656 93120 }
13657
13658 122400 SAMPLE *temp_sample = (SAMPLE *)sfxdata[i].dat;
13659
13660
2/2
✓ Branch 0 taken 94605 times.
✓ Branch 1 taken 27795 times.
122400 if(customsfxdata[j].data!=NULL)
13661 {
13662 // delete [] customsfxdata[j].data;
13663 27795 free(customsfxdata[j].data);
13664 27795 }
13665
13666 // customsfxdata[j].data = new byte[(temp_sample->bits==8?1:2)*temp_sample->len];
13667 122400 customsfxdata[j].data = calloc((temp_sample->bits==8?1:2)*(temp_sample->stereo == 0 ? 1 : 2)*temp_sample->len,1);
13668 122400 customsfxdata[j].bits = temp_sample->bits;
13669 122400 customsfxdata[j].stereo = temp_sample->stereo;
13670 122400 customsfxdata[j].freq = temp_sample->freq;
13671 122400 customsfxdata[j].priority = temp_sample->priority;
13672 122400 customsfxdata[j].len = temp_sample->len;
13673 122400 customsfxdata[j].loop_start = temp_sample->loop_start;
13674 122400 customsfxdata[j].loop_end = temp_sample->loop_end;
13675 122400 customsfxdata[j].param = temp_sample->param;
13676 122400 memcpy(customsfxdata[j].data, (temp_sample->data), (temp_sample->bits==8?1:2)*(temp_sample->stereo==0 ? 1 : 2)*temp_sample->len);
13677 122400 i=j;
13678 122400 }
13679 480 }
13680
13681 extern char *guy_string[eMAXGUYS];
13682 extern const char *old_guy_string[OLDMAXGUYS];
13683
13684 480 int32_t readguys(PACKFILE *f, zquestheader *Header)
13685 {
13686
2/2
✓ Branch 0 taken 457 times.
✓ Branch 1 taken 23 times.
480 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_guys);
13687
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 480 times.
480 if (should_skip) return 0;
13688
13689 dword dummy;
13690 word guy_cversion;
13691 480 word guyversion=0;
13692
13693
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 457 times.
480 if(Header->zelda_version >= 0x193)
13694 {
13695 //section version info
13696
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 if(!p_igetw(&guyversion,f))
13697 {
13698 return qe_invalid;
13699 }
13700
13701 457 FFCore.quest_format[vGuys] = guyversion;
13702
13703 // Note: this is the only instance where "cversion" is ever used.
13704
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 if(!p_igetw(&guy_cversion,f))
13705 {
13706 return qe_invalid;
13707 }
13708
13709 //section size
13710
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 if(!p_igetl(&dummy,f))
13711 {
13712 return qe_invalid;
13713 }
13714 457 }
13715
13716
2/2
✓ Branch 0 taken 398 times.
✓ Branch 1 taken 82 times.
480 if(guyversion > 3)
13717 {
13718
2/2
✓ Branch 0 taken 203776 times.
✓ Branch 1 taken 398 times.
204174 for(int32_t i=0; i<MAXGUYS; i++)
13719 {
13720 char tempname[64];
13721
13722 // rev. 1511 : guyversion = 23. upped to 512 editable enemies. -Gleeok
13723 // if guyversion < 23 then there is only 256 enemies in the packfile, so default the rest.
13724
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 203776 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
203776 if(guyversion < 23 && i >= OLDBETAMAXGUYS)
13725 {
13726 memset(tempname, 0, sizeof(char)*64);
13727 sprintf(tempname, "e%03d", i);
13728 strcpy(guy_string[i], tempname);
13729
13730 continue;
13731 }
13732
13733
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(!pfread(tempname, 64, f))
13734 {
13735 return qe_invalid;
13736 }
13737
13738 // Don't retain names of uneditable enemy entries!
13739 // for version upgrade to 2.5
13740
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 203776 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
203776 if(guyversion < 23 && i >= 177)
13741 {
13742 // some of the older builds have names such as 'zz123',
13743 // (this order gets messed up with some eXXX and some zzXXX)
13744 // so let's update to the newer naming convection. -Gleeok
13745 char tmpbuf[64];
13746 memset(tmpbuf, 0, sizeof(char)*64);
13747 sprintf(tmpbuf, "zz%03d", i);
13748
13749 if(memcmp(tempname, tmpbuf, size_t(5)) == 0)
13750 {
13751 memset(tempname, 0, sizeof(char)*64);
13752 sprintf(tempname, "e%03d", i);
13753 }
13754 }
13755
13756
6/6
✓ Branch 0 taken 70446 times.
✓ Branch 1 taken 133330 times.
✓ Branch 2 taken 66864 times.
✓ Branch 3 taken 3582 times.
✓ Branch 4 taken 58082 times.
✓ Branch 5 taken 8782 times.
203776 if(i >= OLDMAXGUYS || strlen(tempname)<1 || tempname[strlen(tempname)-1]!=' ')
13757 {
13758 194994 guy_string[i][0] = '\0';
13759 194994 strncat(guy_string[i], tempname, 64 - 1);
13760 194994 }
13761 else
13762 {
13763 8782 strcpy(guy_string[i],old_guy_string[i]);
13764 }
13765 203776 }
13766 398 }
13767 else
13768 {
13769
2/2
✓ Branch 0 taken 41984 times.
✓ Branch 1 taken 82 times.
42066 for(int32_t i=0; i<eMAXGUYS; i++)
13770 {
13771 41984 sprintf(guy_string[i],"zz%03d",i);
13772 41984 }
13773
13774
2/2
✓ Branch 0 taken 14514 times.
✓ Branch 1 taken 82 times.
14596 for(int32_t i=0; i<OLDMAXGUYS; i++)
13775 {
13776 14514 strcpy(guy_string[i],old_guy_string[i]);
13777 14514 }
13778 }
13779
13780
13781 //finally... section data
13782 480 init_guys(guyversion); //using default data for now...
13783
13784 // Goriya guy fix
13785
3/6
✓ Branch 0 taken 398 times.
✓ Branch 1 taken 82 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 398 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
480 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<7)))
13786 {
13787
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 60 times.
82 if(get_qr(qr_NEWENEMYTILES))
13788 {
13789 60 guysbuf[gGORIYA].tile=130;
13790 60 guysbuf[gGORIYA].e_tile=130;
13791 60 }
13792 82 }
13793
13794
2/2
✓ Branch 0 taken 457 times.
✓ Branch 1 taken 23 times.
480 if(Header->zelda_version < 0x193)
13795 {
13796
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 5 times.
23 if(get_bit(deprecated_rules,46))
13797 {
13798 5 guysbuf[eDODONGO].cset=14;
13799 5 guysbuf[eDODONGO].bosspal=spDIG;
13800 5 }
13801 23 }
13802 // Not sure when this first changed, but it's necessary for 2.10, at least
13803 // @TODO: @BUG:1.92 - 1.84? Figure this out exactly for the final 2.50 release.
13804 //2.10 Fixes
13805
3/6
✓ Branch 0 taken 398 times.
✓ Branch 1 taken 82 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 398 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
480 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<18)))
13806 {
13807 82 guysbuf[eWWIZ].editorflags |= ENEMY_FLAG5;
13808 82 guysbuf[eMOLDORM].editorflags |= ENEMY_FLAG6;
13809 82 guysbuf[eMANHAN].editorflags |= ENEMY_FLAG6;
13810 82 guysbuf[eCENT1].attributes[2] = 1;
13811 82 guysbuf[eCENT2].attributes[2] = 1;
13812 82 }
13813
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 480 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
480 if((Header->zelda_version <= 0x255) || (Header->zelda_version == 0x255 && Header->build < 47) )
13814 {
13815 480 guysbuf[eWPOLSV].defense[edefWhistle] = ed1HKO;
13816 480 }
13817
2/2
✓ Branch 0 taken 398 times.
✓ Branch 1 taken 82 times.
480 if(Header->zelda_version <= 0x210)
13818 {
13819 82 guysbuf[eGLEEOK1F].attributes[5] = 16;
13820 82 guysbuf[eGLEEOK2F].attributes[5] = 16;
13821 82 guysbuf[eGLEEOK3F].attributes[5] = 16;
13822 82 guysbuf[eGLEEOK4F].attributes[5] = 16;
13823
13824 82 guysbuf[eWIZ1].attributes[3] = 1; //only set the enemy that needs backward compat, not all of them.
13825 82 guysbuf[eBATROBE].attributes[3] = 1;
13826 //guysbuf[eSUMMONER].misc4 = 1;
13827 82 guysbuf[eWWIZ].attributes[3] = 1;
13828 82 guysbuf[eDODONGO].deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
13829 82 guysbuf[eDODONGOBS].deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
13830 82 }
13831
2/2
✓ Branch 0 taken 468 times.
✓ Branch 1 taken 12 times.
480 if(Header->zelda_version == 0x190)
13832 {
13833 12 al_trace("Setting Tribble Properties for Version: %x", Header->zelda_version);
13834 12 guysbuf[eKEESETRIB].attributes[2] = eVIRE; //1.90 and earlier, keese and gel tribbles grew up into
13835 12 guysbuf[eGELTRIB].attributes[2] = eZOL; //normal vires, and zols -Z (16th January, 2019 )
13836 12 }
13837
13838 // The versions here may not be correct
13839 // zelda_version>=0x211 handled at guyversion<24
13840
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 462 times.
480 if(Header->zelda_version <= 0x190)
13841 {
13842 18 guysbuf[eCENT1].attributes[2] = 0;
13843 18 guysbuf[eCENT2].attributes[2] = 0;
13844 18 guysbuf[eMOLDORM].attributes[1] = 0;
13845 //guysbuf[eKEESETRIB].misc3 = eVIRE; //1.90 and earlier, keese and gel tribbles grew up into
13846 //guysbuf[eGELTRIB].misc3 = eZOL; //normal vires, and zols -Z (16th January, 2019 )
13847 18 }
13848
2/2
✓ Branch 0 taken 398 times.
✓ Branch 1 taken 64 times.
462 else if(Header->zelda_version <= 0x210)
13849 {
13850 64 guysbuf[eCENT1].attributes[2] = 1;
13851 64 guysbuf[eCENT2].attributes[2] = 1;
13852 64 guysbuf[eMOLDORM].attributes[1] = 0;
13853 64 }
13854
13855
2/2
✓ Branch 0 taken 398 times.
✓ Branch 1 taken 82 times.
480 if ( Header->zelda_version < 0x211 ) //Default rest rates for phantom ghinis, peahats and keese in < 2.50 quests
13856 {
13857 82 guysbuf[eKEESE1].attributes[15] = 120;
13858 82 guysbuf[eKEESE2].attributes[15] = 120;
13859 82 guysbuf[eKEESE3].attributes[15] = 120;
13860 82 guysbuf[eKEESETRIB].attributes[15] = 120;
13861 82 guysbuf[eKEESE1].attributes[16] = 16;
13862 82 guysbuf[eKEESE2].attributes[16] = 16;
13863 82 guysbuf[eKEESE3].attributes[16] = 16;
13864 82 guysbuf[eKEESETRIB].attributes[16] = 16;
13865
13866 82 guysbuf[ePEAHAT].attributes[15] = 80;
13867 82 guysbuf[ePEAHAT].attributes[16] = 16;
13868
13869 82 guysbuf[eGHINI2].attributes[15] = 120;
13870 82 guysbuf[eGHINI2].attributes[16] = 10;
13871
13872
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 66 times.
82 if (replay_version_check(20))
13873 {
13874 66 guysbuf[eGHINI2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13875 66 guysbuf[eMOLDORM].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13876 66 guysbuf[eKEESETRIB].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13877 66 guysbuf[eKEESE3].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13878 66 guysbuf[eKEESE2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13879 66 guysbuf[eKEESE1].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13880 66 guysbuf[eTEK1].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13881 66 guysbuf[eTEK2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13882 66 guysbuf[ePEAHAT].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13883 66 guysbuf[eROCK].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13884 66 guysbuf[eTRAP].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13885 66 guysbuf[eWALLM].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13886 66 guysbuf[ePOLSV].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13887 66 guysbuf[eMANHAN].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13888 66 guysbuf[eGLEEOK1].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13889 66 guysbuf[eGLEEOK2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13890 66 guysbuf[eGLEEOK3].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13891 66 guysbuf[eGLEEOK4].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13892 66 guysbuf[eDIG1].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13893 66 guysbuf[eDIG3].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13894 66 guysbuf[eDIGPUP1].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13895 66 guysbuf[eDIGPUP2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13896 66 guysbuf[eDIGPUP3].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13897 66 guysbuf[eDIGPUP4].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13898 66 guysbuf[eRAQUAM].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13899 66 guysbuf[eITEMFAIRY].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13900 66 guysbuf[eFIRE].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13901 66 guysbuf[eMANHAN2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13902 66 guysbuf[eTRAP_H].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13903 66 guysbuf[eTRAP_V].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13904 66 guysbuf[eTRAP_LR].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13905 66 guysbuf[eTRAP_UD].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13906 66 guysbuf[ePATRA1].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13907 66 guysbuf[ePATRA2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13908 66 guysbuf[ePATRABS].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13909 66 guysbuf[eBAT].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13910 66 guysbuf[eGLEEOK1F].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13911 66 guysbuf[eGLEEOK2F].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13912 66 guysbuf[eGLEEOK3F].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13913 66 guysbuf[eGLEEOK4F].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13914 66 guysbuf[eTRIGGER].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13915 66 guysbuf[ePATRAL2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13916 66 guysbuf[ePATRAL3].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13917 66 guysbuf[eGOHMA1].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13918 66 guysbuf[eGOHMA2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13919 66 guysbuf[eGOHMA3].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13920 66 guysbuf[eGOHMA4].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13921 66 guysbuf[eMPOLSV].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13922 66 guysbuf[eWPOLSV].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13923 66 }
13924 82 }
13925
13926
13927
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 398 times.
480 if(guyversion<=2)
13928 {
13929 82 return readherosprites2(f, guyversion==2?0:-1);
13930 }
13931
13932
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 if(guyversion > 3)
13933 {
13934 398 guydata tempguy;
13935
13936
2/2
✓ Branch 0 taken 203776 times.
✓ Branch 1 taken 398 times.
204174 for(int32_t i=0; i<MAXGUYS; i++)
13937 {
13938
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(guyversion < 23) // May 2012 : 512 max enemies
13939 {
13940 if(i >= OLDBETAMAXGUYS)
13941 {
13942 guysbuf[i].clear();
13943 continue;
13944 }
13945 }
13946
13947 203776 tempguy.clear();
13948
13949 uint32_t flags1;
13950 uint32_t flags2;
13951
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(!p_igetl(&(flags1),f))
13952 {
13953 return qe_invalid;
13954 }
13955
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(!p_igetl(&(flags2),f))
13956 {
13957 return qe_invalid;
13958 }
13959 203776 tempguy.flags = guy_flags(flags1) | guy_flags(uint64_t(flags2)<<32ULL);
13960
13961
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 105472 times.
203776 if ( guyversion >= 36 ) //expanded tiles
13962 {
13963
1/2
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
98304 if(!p_igetl(&(tempguy.tile),f))
13964 {
13965 return qe_invalid;
13966 }
13967 98304 }
13968 else
13969 {
13970
1/2
✓ Branch 0 taken 105472 times.
✗ Branch 1 not taken.
105472 if(!p_igetw(&(tempguy.tile),f))
13971 {
13972 return qe_invalid;
13973 }
13974 }
13975
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(!p_getc(&(tempguy.width),f))
13976 {
13977 return qe_invalid;
13978 }
13979
13980
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(!p_getc(&(tempguy.height),f))
13981 {
13982 return qe_invalid;
13983 }
13984
13985
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 105472 times.
203776 if ( guyversion >= 36 ) //expanded tiles
13986 {
13987
1/2
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
98304 if(!p_igetl(&(tempguy.s_tile),f))
13988 {
13989 return qe_invalid;
13990 }
13991 98304 }
13992 else
13993 {
13994
1/2
✓ Branch 0 taken 105472 times.
✗ Branch 1 not taken.
105472 if(!p_igetw(&(tempguy.s_tile),f))
13995 {
13996 return qe_invalid;
13997 }
13998 }
13999
14000
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(!p_getc(&(tempguy.s_width),f))
14001 {
14002 return qe_invalid;
14003 }
14004
14005
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(!p_getc(&(tempguy.s_height),f))
14006 {
14007 return qe_invalid;
14008 }
14009
14010
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 105472 times.
203776 if ( guyversion >= 36 ) //expanded tiles
14011 {
14012
1/2
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
98304 if(!p_igetl(&(tempguy.e_tile),f))
14013 {
14014 return qe_invalid;
14015 }
14016 98304 }
14017 else
14018 {
14019
1/2
✓ Branch 0 taken 105472 times.
✗ Branch 1 not taken.
105472 if(!p_igetw(&(tempguy.e_tile),f))
14020 {
14021 return qe_invalid;
14022 }
14023 }
14024
14025
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(!p_getc(&(tempguy.e_width),f))
14026 {
14027 return qe_invalid;
14028 }
14029
14030
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(!p_getc(&(tempguy.e_height),f))
14031 {
14032 return qe_invalid;
14033 }
14034
14035
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(!p_igetw(&(tempguy.hp),f))
14036 {
14037 return qe_invalid;
14038 }
14039
14040
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(!p_igetw(&(tempguy.family),f))
14041 {
14042 return qe_invalid;
14043 }
14044
14045
1/12
✗ Branch 0 not taken.
✓ Branch 1 taken 203776 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
203776 if(guyversion < 9 && (i==eDKNUT1 || i==eDKNUT2 || i==eDKNUT3 || i==eDKNUT4 || i==eDKNUT5)) // Whoops, forgot about Darknuts...
14046 {
14047 if(get_qr(qr_NEWENEMYTILES))
14048 {
14049 tempguy.s_tile=tempguy.e_tile+120;
14050 tempguy.s_width=tempguy.e_width;
14051 tempguy.s_height=tempguy.e_height;
14052 }
14053 else tempguy.s_tile=860;
14054 }
14055
14056
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(!p_igetw(&(tempguy.cset),f))
14057 {
14058 return qe_invalid;
14059 }
14060
14061
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(!p_igetw(&(tempguy.anim),f))
14062 {
14063 return qe_invalid;
14064 }
14065
14066
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(!p_igetw(&(tempguy.e_anim),f))
14067 {
14068 return qe_invalid;
14069 }
14070
14071
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(!p_igetw(&(tempguy.frate),f))
14072 {
14073 return qe_invalid;
14074 }
14075
14076
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(!p_igetw(&(tempguy.e_frate),f))
14077 {
14078 return qe_invalid;
14079 }
14080
14081
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(guyversion < 13) // April 2009
14082 {
14083 if(get_bit(deprecated_rules, qr_SLOWENEMYANIM_DEP))
14084 {
14085 tempguy.frate *= 2;
14086 tempguy.e_frate *= 2;
14087 }
14088 }
14089
14090
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(guyversion < 14) // May 1 2009
14091 {
14092 if(tempguy.anim==a2FRMSLOW)
14093 {
14094 tempguy.anim=a2FRM;
14095 tempguy.frate *= 2;
14096 }
14097
14098 if(tempguy.e_anim==a2FRMSLOW)
14099 {
14100 tempguy.e_anim=a2FRM;
14101 tempguy.e_frate *= 2;
14102 }
14103
14104 if(tempguy.anim==aFLIPSLOW)
14105 {
14106 tempguy.anim=aFLIP;
14107 tempguy.frate *= 2;
14108 }
14109
14110 if(tempguy.e_anim==aFLIPSLOW)
14111 {
14112 tempguy.e_anim=aFLIP;
14113 tempguy.e_frate *= 2;
14114 }
14115
14116 if(tempguy.anim == aNEWDWALK) tempguy.anim = a4FRM4DIR;
14117
14118 if(tempguy.e_anim == aNEWDWALK) tempguy.e_anim = a4FRM4DIR;
14119
14120 if(tempguy.anim == aNEWPOLV || tempguy.anim == a4FRM3TRAP)
14121 {
14122 tempguy.anim=a4FRM4DIR;
14123 tempguy.s_tile=(get_qr(qr_NEWENEMYTILES) ? tempguy.e_tile : tempguy.tile)+20;
14124 }
14125
14126 if(tempguy.e_anim == aNEWPOLV || tempguy.e_anim == a4FRM3TRAP)
14127 {
14128 tempguy.e_anim=a4FRM4DIR;
14129 tempguy.s_tile=(get_qr(qr_NEWENEMYTILES) ? tempguy.e_tile : tempguy.tile)+20;
14130 }
14131 }
14132
14133
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(!p_igetw(&(tempguy.dp),f))
14134 {
14135 return qe_invalid;
14136 }
14137
14138 //correction for guy fire
14139
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(guyversion < 6)
14140 {
14141 if(i == gFIRE)
14142 tempguy.dp = 2;
14143 }
14144
14145
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(!p_igetw(&(tempguy.wdp),f))
14146 {
14147 return qe_invalid;
14148 }
14149
14150
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(!p_igetw(&(tempguy.weapon),f))
14151 {
14152 return qe_invalid;
14153 }
14154
14155 //correction for bosses using triple, "rising" fireballs
14156
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(guyversion < 5)
14157 {
14158 if(i == eLAQUAM || i == eRAQUAM || i == eGOHMA1 || i == eGOHMA2 ||
14159 i == eGOHMA3 || i == eGOHMA4)
14160 {
14161 if(tempguy.weapon == ewFireball)
14162 tempguy.weapon = ewFireball2;
14163 }
14164 }
14165
14166
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(!p_igetw(&(tempguy.rate),f))
14167 {
14168 return qe_invalid;
14169 }
14170
14171
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(!p_igetw(&(tempguy.hrate),f))
14172 {
14173 return qe_invalid;
14174 }
14175
14176
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(!p_igetw(&(tempguy.step),f))
14177 {
14178 return qe_invalid;
14179 }
14180
14181 // HIGHLY UNORTHODOX UPDATING THING, part 2
14182
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 203776 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
203776 if(fixpolsvoice && tempguy.family==eePOLSV)
14183 {
14184 tempguy.step /= 2;
14185 }
14186
14187
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(!p_igetw(&(tempguy.homing),f))
14188 {
14189 return qe_invalid;
14190 }
14191
14192
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(!p_igetw(&(tempguy.grumble),f))
14193 {
14194 return qe_invalid;
14195 }
14196
14197
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(!p_igetw(&(tempguy.item_set),f))
14198 {
14199 return qe_invalid;
14200 }
14201
14202
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(guyversion>=22) // Version 22: Expand misc attributes to 32 bits
14203 {
14204
2/2
✓ Branch 0 taken 2037760 times.
✓ Branch 1 taken 203776 times.
2241536 for (int q = 0; q < 10; ++q)
14205 {
14206
1/2
✓ Branch 0 taken 2037760 times.
✗ Branch 1 not taken.
2037760 if (!p_igetl(&(tempguy.attributes[q]), f))
14207 {
14208 return qe_invalid;
14209 }
14210 2037760 }
14211 203776 }
14212 else
14213 {
14214 int16_t tempMisc;
14215
14216 for(int q=0;q<10;q++)
14217 {
14218 if (!p_igetw(&tempMisc, f))
14219 {
14220 return qe_invalid;
14221 }
14222 tempguy.attributes[q] = tempMisc;
14223 }
14224
14225 if(guyversion < 13) // April 2009 - a tiny Wizzrobe update
14226 {
14227 if(tempguy.family == eeWIZZ && !(tempguy.attributes[0]))
14228 tempguy.attributes[4] = 74;
14229 }
14230
14231 }
14232
14233
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(!p_igetw(&(tempguy.bgsfx),f))
14234 {
14235 return qe_invalid;
14236 }
14237
14238
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(!p_igetw(&(tempguy.bosspal),f))
14239 {
14240 return qe_invalid;
14241 }
14242
14243
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(!p_igetw(&(tempguy.extend),f))
14244 {
14245 return qe_invalid;
14246 }
14247
14248 //! Enemy Defences
14249
14250 //If a 2.50 quest, use only the 2.5 defences.
14251
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 203776 times.
203776 if(guyversion >= 16 ) // November 2009 - Super Enemy Editor
14252 {
14253
2/2
✓ Branch 0 taken 3871744 times.
✓ Branch 1 taken 203776 times.
4075520 for(int32_t j=0; j<edefLAST; j++)
14254 {
14255
1/2
✓ Branch 0 taken 3871744 times.
✗ Branch 1 not taken.
3871744 if(!p_getc(&(tempguy.defense[j]),f))
14256 {
14257 return qe_invalid;
14258 }
14259 3871744 }
14260 //then copy the generic script defence to all the new script defences
14261
14262 203776 }
14263
14264
14265
14266
14267
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 203776 times.
203776 if(guyversion >= 18)
14268 {
14269
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(!p_getc(&(tempguy.hitsfx),f))
14270 {
14271 return qe_invalid;
14272 }
14273
14274
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(!p_getc(&(tempguy.deadsfx),f))
14275 {
14276 return qe_invalid;
14277 }
14278 203776 }
14279
14280
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(guyversion >= 22)
14281 {
14282
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(!p_igetl(&(tempguy.attributes[10]), f))
14283 {
14284 return qe_invalid;
14285 }
14286
14287
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(!p_igetl(&(tempguy.attributes[11]),f))
14288 {
14289 return qe_invalid;
14290 }
14291 203776 }
14292 else if(guyversion >= 19)
14293 {
14294 int16_t tempMisc;
14295
14296 if(!p_igetw(&tempMisc,f))
14297 {
14298 return qe_invalid;
14299 }
14300
14301 tempguy.attributes[10] = tempMisc;
14302
14303 if(!p_igetw(&tempMisc,f))
14304 {
14305 return qe_invalid;
14306 }
14307
14308 tempguy.attributes[11] = tempMisc;
14309 }
14310
14311 //If a 2.54 or later quest, use all of the defences.
14312
2/2
✓ Branch 0 taken 105472 times.
✓ Branch 1 taken 98304 times.
203776 if(guyversion > 24) // Add new guyversion conditional statement
14313 {
14314
2/2
✓ Branch 0 taken 2162688 times.
✓ Branch 1 taken 98304 times.
2260992 for(int32_t j=edefLAST; j<edefLAST255; j++)
14315 {
14316
1/2
✓ Branch 0 taken 2162688 times.
✗ Branch 1 not taken.
2162688 if(!p_getc(&(tempguy.defense[j]),f))
14317 {
14318 return qe_invalid;
14319 }
14320 2162688 }
14321 98304 }
14322
14323
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 105472 times.
203776 if(guyversion <= 24) // Port over generic script settings from old quests in the new editor.
14324 {
14325
2/2
✓ Branch 0 taken 1054720 times.
✓ Branch 1 taken 105472 times.
1160192 for(int32_t j=edefSCRIPT01; j<=edefSCRIPT10; j++)
14326 {
14327 1054720 tempguy.defense[j] = tempguy.defense[edefSCRIPT] ;
14328 1054720 }
14329 105472 }
14330
14331 //tilewidth, tileheight, hitwidth, hitheight, hitzheight, hitxofs, hityofs, hitzofs
14332
2/2
✓ Branch 0 taken 105472 times.
✓ Branch 1 taken 98304 times.
203776 if(guyversion > 25)
14333 {
14334
1/2
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
98304 if(!p_igetl(&(tempguy.txsz),f))
14335 {
14336 return qe_invalid;
14337 }
14338
1/2
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
98304 if(!p_igetl(&(tempguy.tysz),f))
14339 {
14340 return qe_invalid;
14341 }
14342
1/2
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
98304 if(!p_igetl(&(tempguy.hxsz),f))
14343 {
14344 return qe_invalid;
14345 }
14346
1/2
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
98304 if(!p_igetl(&(tempguy.hysz),f))
14347 {
14348 return qe_invalid;
14349 }
14350
1/2
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
98304 if(!p_igetl(&(tempguy.hzsz),f))
14351 {
14352 return qe_invalid;
14353 }
14354 /* Is it safe to read a fixed with getl, or do I need to typecast it? -Z
14355
14356 */
14357 98304 }
14358 //More Enemy Editor vars for 2.60
14359
2/2
✓ Branch 0 taken 105472 times.
✓ Branch 1 taken 98304 times.
203776 if(guyversion > 26)
14360 {
14361
1/2
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
98304 if(!p_igetl(&(tempguy.hxofs),f))
14362 {
14363 return qe_invalid;
14364 }
14365
1/2
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
98304 if(!p_igetl(&(tempguy.hyofs),f))
14366 {
14367 return qe_invalid;
14368 }
14369
1/2
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
98304 if(!p_igetl(&(tempguy.xofs),f))
14370 {
14371 return qe_invalid;
14372 }
14373
1/2
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
98304 if(!p_igetl(&(tempguy.yofs),f))
14374 {
14375 return qe_invalid;
14376 }
14377
1/2
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
98304 if(!p_igetl(&(tempguy.zofs),f))
14378 {
14379 return qe_invalid;
14380 }
14381 98304 }
14382
14383
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 105472 times.
203776 if(guyversion <= 27) // Port over generic script settings from old quests in the new editor.
14384 {
14385 105472 tempguy.wpnsprite = 0;
14386 105472 }
14387
14388
2/2
✓ Branch 0 taken 105472 times.
✓ Branch 1 taken 98304 times.
203776 if(guyversion > 27)
14389 {
14390
1/2
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
98304 if(!p_igetl(&(tempguy.wpnsprite),f))
14391 {
14392 return qe_invalid;
14393 }
14394 98304 }
14395
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 105472 times.
203776 if(guyversion <= 28) // Port over generic script settings from old quests in the new editor.
14396 {
14397 105472 tempguy.SIZEflags = 0;
14398 105472 }
14399
2/2
✓ Branch 0 taken 105472 times.
✓ Branch 1 taken 98304 times.
203776 if(guyversion > 28)
14400 {
14401
1/2
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
98304 if(!p_igetl(&(tempguy.SIZEflags),f))
14402 {
14403 return qe_invalid;
14404 }
14405
14406 98304 }
14407
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 105472 times.
203776 if(guyversion < 30) // Port over generic script settings from old quests in the new editor.
14408 {
14409 105472 tempguy.frozentile = 0;
14410 105472 tempguy.frozencset = 0;
14411 105472 tempguy.frozenclock = 0;
14412
2/2
✓ Branch 0 taken 1054720 times.
✓ Branch 1 taken 105472 times.
1160192 for ( int32_t q = 0; q < 10; q++ ) tempguy.frozenmisc[q] = 0;
14413 105472 }
14414
2/2
✓ Branch 0 taken 105472 times.
✓ Branch 1 taken 98304 times.
203776 if(guyversion >= 30)
14415 {
14416
1/2
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
98304 if(!p_igetl(&(tempguy.frozentile),f))
14417 {
14418 return qe_invalid;
14419 }
14420
1/2
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
98304 if(!p_igetl(&(tempguy.frozencset),f))
14421 {
14422 return qe_invalid;
14423 }
14424
1/2
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
98304 if(!p_igetl(&(tempguy.frozenclock),f))
14425 {
14426 return qe_invalid;
14427 }
14428
2/2
✓ Branch 0 taken 983040 times.
✓ Branch 1 taken 98304 times.
1081344 for ( int32_t q = 0; q < 10; q++ ) {
14429
1/2
✓ Branch 0 taken 983040 times.
✗ Branch 1 not taken.
983040 if(!p_igetw(&(tempguy.frozenmisc[q]),f))
14430 {
14431 return qe_invalid;
14432 }
14433 983040 }
14434
14435 98304 }
14436
14437
2/2
✓ Branch 0 taken 105472 times.
✓ Branch 1 taken 98304 times.
203776 if(guyversion >= 34)
14438 {
14439
1/2
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
98304 if(!p_igetw(&(tempguy.firesfx),f))
14440 {
14441 return qe_invalid;
14442 }
14443
2/2
✓ Branch 0 taken 1671168 times.
✓ Branch 1 taken 98304 times.
1769472 for(int q=15;q<32;++q)
14444 {
14445
1/2
✓ Branch 0 taken 1671168 times.
✗ Branch 1 not taken.
1671168 if(!p_igetl(&(tempguy.attributes[q]),f))
14446 {
14447 return qe_invalid;
14448 }
14449 1671168 }
14450
14451
2/2
✓ Branch 0 taken 3145728 times.
✓ Branch 1 taken 98304 times.
3244032 for ( int32_t q = 0; q < 32; q++ ) {
14452
1/2
✓ Branch 0 taken 3145728 times.
✗ Branch 1 not taken.
3145728 if(!p_igetl(&(tempguy.movement[q]),f))
14453 {
14454 return qe_invalid;
14455 }
14456 3145728 }
14457
2/2
✓ Branch 0 taken 3145728 times.
✓ Branch 1 taken 98304 times.
3244032 for ( int32_t q = 0; q < 32; q++ ) {
14458
1/2
✓ Branch 0 taken 3145728 times.
✗ Branch 1 not taken.
3145728 if(!p_igetl(&(tempguy.new_weapon[q]),f))
14459 {
14460 return qe_invalid;
14461 }
14462 3145728 }
14463
1/2
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
98304 if(!p_igetw(&(tempguy.script),f))
14464 {
14465 return qe_invalid;
14466 }
14467
2/2
✓ Branch 0 taken 786432 times.
✓ Branch 1 taken 98304 times.
884736 for ( int32_t q = 0; q < 8; q++ )
14468 {
14469
1/2
✓ Branch 0 taken 786432 times.
✗ Branch 1 not taken.
786432 if(!p_igetl(&(tempguy.initD[q]),f))
14470 {
14471 return qe_invalid;
14472 }
14473 786432 }
14474
2/2
✓ Branch 0 taken 196608 times.
✓ Branch 1 taken 98304 times.
294912 for ( int32_t q = 0; q < 2; q++ )
14475 {
14476 int32_t temp;
14477
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(!p_igetl(&temp,f))
14478 {
14479 return qe_invalid;
14480 }
14481 196608 }
14482
14483 98304 }
14484
14485
2/2
✓ Branch 0 taken 105472 times.
✓ Branch 1 taken 98304 times.
203776 if(guyversion >= 37)
14486 {
14487
1/2
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
98304 if(!p_igetl(&(tempguy.editorflags),f))
14488 {
14489 return qe_invalid;
14490 }
14491 98304 }
14492
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 105472 times.
203776 if ( guyversion < 37 ) { tempguy.editorflags = 0; }
14493
2/2
✓ Branch 0 taken 105472 times.
✓ Branch 1 taken 98304 times.
203776 if(guyversion >= 38)
14494 {
14495
1/2
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
98304 if(!p_igetl(&(tempguy.attributes[12]),f))
14496 {
14497 return qe_invalid;
14498 }
14499
1/2
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
98304 if(!p_igetl(&(tempguy.attributes[13]),f))
14500 {
14501 return qe_invalid;
14502 }
14503
1/2
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
98304 if(!p_igetl(&(tempguy.attributes[14]),f))
14504 {
14505 return qe_invalid;
14506 }
14507
14508 98304 }
14509
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 105472 times.
203776 if ( guyversion < 38 )
14510 {
14511 105472 tempguy.attributes[12] = 0;
14512 105472 tempguy.attributes[13] = 0;
14513 105472 tempguy.attributes[14] = 0;
14514 105472 }
14515
14516
2/2
✓ Branch 0 taken 105472 times.
✓ Branch 1 taken 98304 times.
203776 if ( guyversion >= 39 )
14517 {
14518
2/2
✓ Branch 0 taken 786432 times.
✓ Branch 1 taken 98304 times.
884736 for ( int32_t q = 0; q < 8; q++ )
14519 {
14520
2/2
✓ Branch 0 taken 51118080 times.
✓ Branch 1 taken 786432 times.
51904512 for ( int32_t w = 0; w < 65; w++ )
14521 {
14522
1/2
✓ Branch 0 taken 51118080 times.
✗ Branch 1 not taken.
51118080 if(!p_getc(&(tempguy.initD_label[q][w]),f))
14523 {
14524 return qe_invalid;
14525 }
14526 51118080 }
14527
2/2
✓ Branch 0 taken 499712 times.
✓ Branch 1 taken 286720 times.
786432 if(guyversion < 54)
14528 {
14529 byte dummybyte;
14530
2/2
✓ Branch 0 taken 18636800 times.
✓ Branch 1 taken 286720 times.
18923520 for ( int32_t w = 0; w < 65; w++ )
14531
1/2
✓ Branch 0 taken 18636800 times.
✗ Branch 1 not taken.
18636800 if(!p_getc(&dummybyte,f))
14532 return qe_invalid;
14533 286720 }
14534 786432 }
14535
14536
14537 98304 }
14538
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 105472 times.
203776 if ( guyversion < 39 ) //apply old InitD strings to both
14539 {
14540
2/2
✓ Branch 0 taken 843776 times.
✓ Branch 1 taken 105472 times.
949248 for ( int32_t q = 0; q < 8; q++ )
14541 {
14542 843776 sprintf(tempguy.initD_label[q],"InitD[%d]",q);
14543 843776 }
14544 105472 }
14545
4/4
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 105472 times.
✓ Branch 2 taken 62464 times.
✓ Branch 3 taken 35840 times.
203776 if ( guyversion >= 40 && guyversion < 54)
14546
1/2
✓ Branch 0 taken 35840 times.
✗ Branch 1 not taken.
35840 if(!p_igetw(&(tempguy.weap_data.script),f))
14547 return qe_invalid;
14548
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 105472 times.
203776 if ( guyversion < 40 )
14549 105472 tempguy.weap_data.script = 0;
14550 //eweapon script InitD
14551
2/2
✓ Branch 0 taken 105472 times.
✓ Branch 1 taken 98304 times.
203776 if ( guyversion >= 41 )
14552 {
14553
2/2
✓ Branch 0 taken 62464 times.
✓ Branch 1 taken 35840 times.
98304 if(guyversion < 54)
14554
2/2
✓ Branch 0 taken 286720 times.
✓ Branch 1 taken 35840 times.
322560 for ( int32_t q = 0; q < 8; q++ )
14555
1/2
✓ Branch 0 taken 286720 times.
✗ Branch 1 not taken.
286720 if(!p_igetl(&(tempguy.weap_data.initd[q]),f))
14556 35840 return qe_invalid;
14557
1/2
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
98304 if ( guy_cversion < 4 )
14558 {
14559 if ( tempguy.family == eeKEESE )
14560 {
14561
14562 if ( !tempguy.attributes[0] )
14563 {
14564 tempguy.attributes[15] = 120;
14565 tempguy.attributes[16] = 16;
14566
14567 }
14568 }
14569 if ( tempguy.family == eePEAHAT )
14570 {
14571 tempguy.attributes[15] = 80;
14572 tempguy.attributes[16] = 16;
14573 }
14574
14575 if ( tempguy.family == eeGHINI )
14576 {
14577 tempguy.attributes[15] = 120;
14578 tempguy.attributes[16] = 10;
14579 }
14580
14581 }
14582 98304 }
14583
14584
14585
14586 //default weapon sprites (quest version < 2.54)
14587 //port over old defaults -Z
14588
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 105472 times.
203776 if(guyversion < 32)
14589 {
14590
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105472 times.
105472 if ( tempguy.wpnsprite <= 0 )
14591 {
14592
16/20
✗ Branch 0 not taken.
✓ Branch 1 taken 2922 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 89573 times.
✓ Branch 4 taken 820 times.
✓ Branch 5 taken 711 times.
✓ Branch 6 taken 1945 times.
✓ Branch 7 taken 1321 times.
✓ Branch 8 taken 2453 times.
✓ Branch 9 taken 212 times.
✓ Branch 10 taken 78 times.
✓ Branch 11 taken 459 times.
✓ Branch 12 taken 79 times.
✓ Branch 13 taken 928 times.
✓ Branch 14 taken 1857 times.
✓ Branch 15 taken 235 times.
✓ Branch 16 taken 333 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 1546 times.
105472 switch(tempguy.weapon)
14593 {
14594 case wNone:
14595 89573 tempguy.wpnsprite = 0; break;
14596
14597 case wSword:
14598 case wBeam:
14599 case wBrang:
14600 case wBomb:
14601 case wSBomb:
14602 case wLitBomb:
14603 case wLitSBomb:
14604 case wArrow:
14605 case wFire:
14606 case wWhistle:
14607 case wBait:
14608 case wWand:
14609 case wMagic:
14610 case wCatching:
14611 case wWind:
14612 case wRefMagic:
14613 case wRefFireball:
14614 case wRefRock:
14615 case wHammer:
14616 case wHookshot:
14617 case wHSHandle:
14618 case wHSChain:
14619 case wSSparkle:
14620 case wFSparkle:
14621 case wSmack:
14622 case wPhantom:
14623 case wCByrna:
14624 case wRefBeam:
14625 case wStomp:
14626 case lwMax:
14627 case wScript1:
14628 case wScript2:
14629 case wScript3:
14630 case wScript4:
14631 case wScript5:
14632 case wScript6:
14633 case wScript7:
14634 case wScript8:
14635 case wScript9:
14636 case wScript10:
14637 case wIce:
14638 //Cannot use any of these weapons yet.
14639 tempguy.wpnsprite = -1;
14640 break;
14641
14642 case wEnemyWeapons:
14643 2922 case ewFireball: tempguy.wpnsprite = 17; break;
14644
14645 820 case ewArrow: tempguy.wpnsprite = 19; break;
14646 711 case ewBrang: tempguy.wpnsprite = 4; break;
14647 1945 case ewSword: tempguy.wpnsprite = 20; break;
14648 1321 case ewRock: tempguy.wpnsprite = 18; break;
14649 2453 case ewMagic: tempguy.wpnsprite = 21; break;
14650 212 case ewBomb: tempguy.wpnsprite = 78; break;
14651 78 case ewSBomb: tempguy.wpnsprite = 79; break;
14652 459 case ewLitBomb: tempguy.wpnsprite = 76; break;
14653 79 case ewLitSBomb: tempguy.wpnsprite = 77; break;
14654 928 case ewFireTrail: tempguy.wpnsprite = 80; break;
14655 1857 case ewFlame: tempguy.wpnsprite = 35; break;
14656 235 case ewWind: tempguy.wpnsprite = 36; break;
14657 333 case ewFlame2: tempguy.wpnsprite = 81; break;
14658 case ewFlame2Trail: tempguy.wpnsprite = 82; break;
14659 case ewIce: tempguy.wpnsprite = 83; break;
14660 1546 case ewFireball2: tempguy.wpnsprite = 17; break; //fireball (rising)
14661
14662
14663 default: break; //No assign.
14664 }
14665 105472 }
14666 105472 }
14667
14668 //default weapon fire sound (quest version < 2.54)
14669 //port over old defaults and zero new data. -Z
14670
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 105472 times.
203776 if(guyversion < 34)
14671 {
14672
2/2
✓ Branch 0 taken 3375104 times.
✓ Branch 1 taken 105472 times.
3480576 for ( int32_t q = 0; q < 32; q++ )
14673 {
14674 3375104 tempguy.movement[q] = 0;
14675 3375104 tempguy.new_weapon[q] = 0;
14676
14677 3375104 }
14678
14679 //NPC Script attributes.
14680 105472 tempguy.script = 0; //No scripted enemies existed. -Z
14681
2/2
✓ Branch 0 taken 843776 times.
✓ Branch 1 taken 105472 times.
949248 for ( int32_t q = 0; q < 8; q++ ) tempguy.initD[q] = 0; //Script Data
14682
14683
2/2
✓ Branch 0 taken 1793024 times.
✓ Branch 1 taken 105472 times.
1898496 for ( int32_t q = 15; q < 32; q++) tempguy.attributes[q] = 0; //misc 16-32
14684
14685 //old default sounds
14686
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105472 times.
105472 if ( tempguy.firesfx <= 0 )
14687 {
14688
16/20
✗ Branch 0 not taken.
✓ Branch 1 taken 2922 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 89573 times.
✓ Branch 4 taken 820 times.
✓ Branch 5 taken 711 times.
✓ Branch 6 taken 1945 times.
✓ Branch 7 taken 1321 times.
✓ Branch 8 taken 2453 times.
✓ Branch 9 taken 212 times.
✓ Branch 10 taken 78 times.
✓ Branch 11 taken 459 times.
✓ Branch 12 taken 79 times.
✓ Branch 13 taken 928 times.
✓ Branch 14 taken 1857 times.
✓ Branch 15 taken 235 times.
✓ Branch 16 taken 333 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 1546 times.
105472 switch(tempguy.weapon)
14689 {
14690 case wNone:
14691 89573 tempguy.firesfx = 0; break;
14692
14693 case wSword:
14694 case wBeam:
14695 case wBrang:
14696 case wBomb:
14697 case wSBomb:
14698 case wLitBomb:
14699 case wLitSBomb:
14700 case wArrow:
14701 case wFire:
14702 case wWhistle:
14703 case wBait:
14704 case wWand:
14705 case wMagic:
14706 case wCatching:
14707 case wWind:
14708 case wRefMagic:
14709 case wRefFireball:
14710 case wRefRock:
14711 case wHammer:
14712 case wHookshot:
14713 case wHSHandle:
14714 case wHSChain:
14715 case wSSparkle:
14716 case wFSparkle:
14717 case wSmack:
14718 case wPhantom:
14719 case wCByrna:
14720 case wRefBeam:
14721 case wStomp:
14722 case lwMax:
14723 case wScript1:
14724 case wScript2:
14725 case wScript3:
14726 case wScript4:
14727 case wScript5:
14728 case wScript6:
14729 case wScript7:
14730 case wScript8:
14731 case wScript9:
14732 case wScript10:
14733 case wIce:
14734 //Cannot use any of these weapons yet.
14735 tempguy.firesfx = -1;
14736 break;
14737
14738 case wEnemyWeapons:
14739 2922 case ewFireball: tempguy.firesfx = 40; break;
14740
14741 820 case ewArrow: tempguy.firesfx = 1; break; //Ghost.zh has 0?
14742 711 case ewBrang: tempguy.firesfx = 4; break; //Ghost.zh has 0?
14743 1945 case ewSword: tempguy.firesfx = 20; break; //Ghost.zh has 0?
14744 1321 case ewRock: tempguy.firesfx = 51; break;
14745 2453 case ewMagic: tempguy.firesfx = 32; break;
14746 212 case ewBomb: tempguy.firesfx = 3; break; //Ghost.zh has 0?
14747 78 case ewSBomb: tempguy.firesfx = 3; break; //Ghost.zh has 0?
14748 459 case ewLitBomb: tempguy.firesfx = 21; break; //Ghost.zh has 0?
14749 79 case ewLitSBomb: tempguy.firesfx = 21; break; //Ghost.zh has 0?
14750 928 case ewFireTrail: tempguy.firesfx = 13; break;
14751 1857 case ewFlame: tempguy.firesfx = 13; break;
14752 235 case ewWind: tempguy.firesfx = 32; break;
14753 333 case ewFlame2: tempguy.firesfx = 13; break;
14754 case ewFlame2Trail: tempguy.firesfx = 13; break;
14755 case ewIce: tempguy.firesfx = 44; break;
14756 1546 case ewFireball2: tempguy.firesfx = 40; break; //fireball (rising)
14757
14758 //what about special attacks (e.g. summoning == 56)
14759 default: break; //No assign.
14760 }
14761 105472 }
14762 105472 }
14763
14764 //Port hardcoded hit sound to the enemy hitsfx defaults for older quests.
14765
4/6
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 105472 times.
✓ Branch 2 taken 98304 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 98304 times.
203776 if(Header->zelda_version <= 0x250 || ( Header->zelda_version > 0x250 && guyversion < 35 ))
14766 {
14767
2/2
✓ Branch 0 taken 91266 times.
✓ Branch 1 taken 14206 times.
105472 if ( tempguy.hitsfx == 0 ) tempguy.hitsfx = 11;
14768 105472 }
14769 //Keese and bat halt rates.
14770
3/4
✓ Branch 0 taken 105472 times.
✓ Branch 1 taken 98304 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 105472 times.
203776 if ( guyversion < 42 && guy_cversion < 4 )
14771 {
14772
14773
2/2
✓ Branch 0 taken 104143 times.
✓ Branch 1 taken 1329 times.
105472 if ( tempguy.family == eeKEESE )
14774 {
14775
14776
2/2
✓ Branch 0 taken 959 times.
✓ Branch 1 taken 370 times.
1329 if ( !tempguy.attributes[0] )
14777 {
14778 959 tempguy.attributes[15] = 120;
14779 959 tempguy.attributes[16] = 16;
14780
14781 959 }
14782 1329 }
14783
2/2
✓ Branch 0 taken 104996 times.
✓ Branch 1 taken 476 times.
105472 if ( tempguy.family == eePEAHAT )
14784 {
14785 476 tempguy.attributes[15] = 80;
14786 476 tempguy.attributes[16] = 16;
14787 476 }
14788
2/2
✓ Branch 0 taken 105266 times.
✓ Branch 1 taken 206 times.
105472 if ( tempguy.family == eeGHINI )
14789 {
14790 206 tempguy.attributes[15] = 120;
14791 206 tempguy.attributes[16] = 10;
14792 206 }
14793
14794
14795 105472 }
14796
14797
14798 //miscellaneous other corrections
14799 //fix the mirror wizzrobe -DD
14800
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(guyversion < 7)
14801 {
14802 if(i == eMWIZ)
14803 {
14804 tempguy.attributes[1] = 0;
14805 tempguy.attributes[3] = 1;
14806 }
14807 }
14808
14809
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(guyversion < 8)
14810 {
14811 if(i == eGLEEOK1 || i == eGLEEOK2 || i == eGLEEOK3 || i == eGLEEOK4 || i == eGLEEOK1F || i == eGLEEOK2F || i == eGLEEOK3F || i == eGLEEOK4F)
14812 {
14813 // Some of these are deliberately different to NewDefault/defdata.cpp, by the way. -L
14814 tempguy.attributes[4] = 4; //neck length in segments
14815 tempguy.attributes[5] = 8; //neck offset from first body tile
14816 tempguy.attributes[6] = 40; //offset for each subsequent neck tile from the first neck tile
14817 tempguy.attributes[7] = 168; //head offset from first body tile
14818 tempguy.attributes[8] = 228; //flying head offset from first body tile
14819
14820 if(i == eGLEEOK1F || i == eGLEEOK2F || i == eGLEEOK3F || i == eGLEEOK4F)
14821 {
14822 tempguy.attributes[5] += 10; //neck offset from first body tile
14823 tempguy.attributes[7] -= 12; //head offset from first body tile
14824 }
14825 }
14826 }
14827
14828
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(guyversion < 10) // December 2007 - Dodongo CSet fix
14829 {
14830 if(get_bit(deprecated_rules,46) && tempguy.family==eeDONGO && tempguy.attributes[0]==0)
14831 tempguy.bosspal = spDIG;
14832 }
14833
14834
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(guyversion < 11) // December 2007 - Spinning Tile fix
14835 {
14836 if(tempguy.family==eeSPINTILE)
14837 {
14838 tempguy.flags |= guy_superman;
14839 tempguy.item_set = 0; // Don't drop items
14840 tempguy.step = 300;
14841 }
14842 }
14843
14844
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(guyversion < 12) // October 2008 - Flashing Bubble, Rope 2, and Ghini 2 fix
14845 {
14846 if(get_bit(deprecated_rules, qr_NOROPE2FLASH_DEP))
14847 {
14848 if(tempguy.family==eeROPE)
14849 {
14850 tempguy.flags &= ~guy_flashing;
14851 }
14852 }
14853
14854 if(get_bit(deprecated_rules, qr_NOBUBBLEFLASH_DEP))
14855 {
14856 if(tempguy.family==eeBUBBLE)
14857 {
14858 tempguy.flags &= ~guy_flashing;
14859 }
14860 }
14861
14862 if((tempguy.family==eeGHINI)&&(tempguy.attributes[0]))
14863 {
14864 if(get_bit(deprecated_rules, qr_GHINI2BLINK_DEP))
14865 {
14866 tempguy.flags |= guy_blinking;
14867 }
14868
14869 if(get_bit(deprecated_rules, qr_PHANTOMGHINI2_DEP))
14870 {
14871 tempguy.flags |= guy_transparent;
14872 }
14873 }
14874 }
14875
14876
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(guyversion < 15) // July 2009 - Guy Fire and Fairy fix
14877 {
14878 if(i==gFIRE)
14879 {
14880 tempguy.e_anim = aFLIP;
14881 tempguy.e_frate = 24;
14882 }
14883
14884 if(i==gFAIRY)
14885 {
14886 tempguy.e_anim = a2FRM;
14887 tempguy.e_frate = 16;
14888 }
14889 }
14890
14891
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(guyversion < 16) // November 2009 - Super Enemy Editor part 1
14892 {
14893 if(i==0) Z_message("Updating guys to version 16...\n");
14894
14895 update_guy_1(&tempguy);
14896
14897 if(i==eMPOLSV)
14898 {
14899 tempguy.defense[edefARROW] = edCHINK;
14900 tempguy.defense[edefMAGIC] = ed1HKO;
14901 tempguy.defense[edefREFMAGIC] = ed1HKO;
14902 }
14903 }
14904
14905
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(guyversion < 17) // December 2009
14906 {
14907 if(tempguy.family==eePROJECTILE)
14908 {
14909 tempguy.attributes[0] = 0;
14910 }
14911 }
14912
14913
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(guyversion < 18) // January 2010
14914 {
14915 bool boss = (tempguy.family == eeAQUA || tempguy.family==eeDONGO || tempguy.family == eeMANHAN || tempguy.family == eeGHOMA || tempguy.family==eeDIG
14916 || tempguy.family == eeGLEEOK || tempguy.family==eePATRA || tempguy.family == eeGANON || tempguy.family==eeMOLD);
14917
14918 tempguy.hitsfx = (boss && tempguy.family != eeMOLD && tempguy.family != eeDONGO && tempguy.family != eeDIG) ? WAV_GASP : 0;
14919 tempguy.deadsfx = (boss && (tempguy.family != eeDIG || tempguy.attributes[9] == 0)) ? WAV_GASP : WAV_EDEAD;
14920
14921 if(tempguy.family == eeAQUA)
14922 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eRAQUAM].defense[j];
14923 else if(tempguy.family == eeMANHAN)
14924 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eMANHAN].defense[j];
14925 else if(tempguy.family==eePATRA)
14926 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eGLEEOK1].defense[j];
14927 else if(tempguy.family==eeGHOMA)
14928 {
14929 for(int32_t j=0; j<edefLAST; j++)
14930 tempguy.defense[j] = default_guys[eGOHMA1].defense[j];
14931
14932 tempguy.defense[edefARROW] = ((tempguy.attributes[0]==3) ? edCHINKL8 : (tempguy.attributes[0]==2) ? edCHINKL4 : 0);
14933
14934 if(tempguy.attributes[0]==3 && !tempguy.weapon) tempguy.weapon = ewFlame;
14935
14936 tempguy.attributes[0]--;
14937 }
14938 else if(tempguy.family == eeGLEEOK)
14939 {
14940 for(int32_t j=0; j<edefLAST; j++)
14941 tempguy.defense[j] = default_guys[eGLEEOK1].defense[j];
14942
14943 if(tempguy.attributes[2]==1 && !tempguy.weapon) tempguy.weapon = ewFlame;
14944 }
14945 else if(tempguy.family == eeARMOS)
14946 {
14947 tempguy.family=eeWALK;
14948 tempguy.hrate = 0;
14949 tempguy.attributes[9] = tempguy.attributes[0];
14950 tempguy.attributes[0] = tempguy.attributes[1] = tempguy.attributes[2] = tempguy.attributes[3] = tempguy.attributes[4] = tempguy.attributes[5] = tempguy.attributes[6] = tempguy.attributes[7] = 0;
14951 tempguy.attributes[0] = tempguy.attributes[1] = tempguy.attributes[2] = tempguy.attributes[3] = tempguy.attributes[4] = tempguy.attributes[5] = tempguy.attributes[6] = tempguy.attributes[7] = 0;
14952 tempguy.attributes[8] = e9tARMOS;
14953 }
14954 else if(tempguy.family == eeGHINI && !tempguy.attributes[0])
14955 {
14956 tempguy.family=eeWALK;
14957 tempguy.hrate = 0;
14958 tempguy.attributes[0] = tempguy.attributes[1] = tempguy.attributes[2] = tempguy.attributes[3] = tempguy.attributes[4] = tempguy.attributes[5] =
14959 tempguy.attributes[6] = tempguy.attributes[7] = tempguy.attributes[8] = tempguy.attributes[9] = 0;
14960 }
14961
14962 // Spawn animation flags
14963 if(tempguy.family == eeWALK && (tempguy.flags&guy_armos || tempguy.flags&guy_ghini))
14964 tempguy.flags |= guy_fade_flicker;
14965 else
14966 tempguy.flags &= (guy_flags)0x0F00000F; // Get rid of the unused flags!
14967 }
14968
14969
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(guyversion < 20) // April 2010
14970 {
14971 if(tempguy.family == eeTRAP)
14972 {
14973 tempguy.attributes[1] = tempguy.attributes[9];
14974
14975 if(tempguy.attributes[9]>=1)
14976 {
14977 tempguy.attributes[0]++;
14978 }
14979
14980 tempguy.attributes[9] = 0;
14981 }
14982
14983 // Bomb Blast fix
14984 if(tempguy.weapon==ewBomb && tempguy.family!=eeROPE && (tempguy.family!=eeWALK || tempguy.attributes[1] != e2tBOMBCHU))
14985 tempguy.weapon = ewLitBomb;
14986 else if(tempguy.weapon==ewSBomb && tempguy.family!=eeROPE && (tempguy.family!=eeWALK || tempguy.attributes[1] != e2tBOMBCHU))
14987 tempguy.weapon = ewLitSBomb;
14988 }
14989
14990
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(guyversion < 21) // September 2011
14991 {
14992 if(tempguy.family == eeKEESE || tempguy.family == eeKEESETRIB)
14993 {
14994 if(tempguy.family == eeKEESETRIB)
14995 {
14996 tempguy.family = eeKEESE;
14997 tempguy.attributes[1] = e2tKEESETRIB;
14998 tempguy.attributes[0] = 0;
14999 }
15000
15001 tempguy.rate = 2;
15002 tempguy.hrate = 8;
15003 tempguy.homing = 0;
15004 tempguy.step= (tempguy.family == eeKEESE && tempguy.attributes[0] ? 100:62);
15005 }
15006 else if(tempguy.family == eePEAHAT || tempguy.family==eePATRA)
15007 {
15008 if(tempguy.family == eePEAHAT)
15009 {
15010 tempguy.rate = 4;
15011 tempguy.step = 62;
15012 }
15013 else
15014 tempguy.step = 25;
15015
15016 tempguy.hrate = 8;
15017 tempguy.homing = 0;
15018 }
15019 else if(tempguy.family == eeDIG || tempguy.family == eeMANHAN)
15020 {
15021 if(tempguy.family == eeMANHAN)
15022 tempguy.step=50;
15023
15024 tempguy.hrate = 16;
15025 tempguy.homing = 0;
15026 }
15027 else if(tempguy.family == eeGLEEOK)
15028 {
15029 tempguy.rate = 2;
15030 tempguy.homing = 0;
15031 tempguy.hrate = 9;
15032 tempguy.step=89;
15033 }
15034 else if(tempguy.family == eeGHINI)
15035 {
15036 tempguy.rate = 4;
15037 tempguy.hrate = 12;
15038 tempguy.step=62;
15039 tempguy.homing = 0;
15040 }
15041
15042 // Bigdig random rate fix
15043 if(tempguy.family==eeDIG && tempguy.attributes[9]==1)
15044 {
15045 tempguy.rate = 2;
15046 }
15047 }
15048
15049
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(guyversion < 24) // November 2012
15050 {
15051 if(tempguy.family==eeLANM)
15052 tempguy.attributes[2] = 1;
15053 else if(tempguy.family==eeMOLD)
15054 tempguy.attributes[1] = 0;
15055 }
15056
15057
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 105472 times.
203776 if(guyversion < 33) //Whistle defence did not exist before this version of 2.54. -Z
15058 {
15059
2/2
✓ Branch 0 taken 1436 times.
✓ Branch 1 taken 104036 times.
105472 if(tempguy.family!=eeDIG)
15060 {
15061 104036 tempguy.defense[edefWhistle] = edIGNORE; //Might need to be ignore, universally.
15062 104036 }
15063
15064 105472 }
15065 // does not seem to solve the issue!
15066
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if ( Header->zelda_version <= 0x210 )
15067 {
15068 al_trace("Detected version %d for dodongo patch.\n",Header->zelda_version);
15069 if ( tempguy.family == eeDONGO )
15070 {
15071 tempguy.deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
15072 }
15073 }
15074
15075
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 105472 times.
203776 if(guyversion >= 42)
15076 {
15077
2/2
✓ Branch 0 taken 95744 times.
✓ Branch 1 taken 2560 times.
98304 if(guyversion >= 47)
15078 {
15079
1/2
✓ Branch 0 taken 95744 times.
✗ Branch 1 not taken.
95744 if(!p_igetl(&(tempguy.moveflags),f))
15080 {
15081 return qe_invalid;
15082 }
15083 95744 }
15084 else
15085 {
15086 byte fl;
15087
1/2
✓ Branch 0 taken 2560 times.
✗ Branch 1 not taken.
2560 if(!p_getc(&fl,f))
15088 {
15089 return qe_invalid;
15090 }
15091 2560 tempguy.moveflags = (move_flags)fl;
15092 }
15093 98304 }
15094 else
15095 {
15096
7/8
✓ Branch 0 taken 3146 times.
✓ Branch 1 taken 83246 times.
✓ Branch 2 taken 2777 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 973 times.
✓ Branch 5 taken 658 times.
✓ Branch 6 taken 510 times.
✓ Branch 7 taken 14162 times.
105472 switch(tempguy.family)
15097 {
15098 //No gravity; floats over pits
15099 case eeTEK: case eePEAHAT: case eeROCK: case eeTRAP:
15100 case eePROJECTILE: case eeSPINTILE: case eeKEESE: case eeFIRE:
15101 //Special (bosses, etc)
15102 case eeFAIRY: case eeGUY: case eeNONE: case eeZORA:
15103 case eeAQUA: case eeDIG: case eeGHOMA: case eeGANON:
15104 case eePATRA: case eeGLEEOK: case eeMOLD: case eeMANHAN:
15105 83246 tempguy.moveflags = move_can_pitwalk;
15106 83246 break;
15107 //No gravity, but falls in pits
15108 case eeLEV:
15109 973 tempguy.moveflags = move_can_pitfall;
15110 973 break;
15111 //Bosses that respect pits
15112 case eeDONGO:
15113 658 tempguy.moveflags = move_obeys_grav;
15114 658 break;
15115 case eeLANM:
15116 510 tempguy.moveflags = move_none;
15117 510 break;
15118 //Gravity, floats over pits
15119 case eeWIZZ: case eeWALLM: case eeGHINI:
15120 2777 tempguy.moveflags = move_obeys_grav | move_can_pitwalk;
15121 2777 break;
15122 //Gravity and falls in pits
15123 case eeWALK:
15124
4/4
✓ Branch 0 taken 13449 times.
✓ Branch 1 taken 713 times.
✓ Branch 2 taken 540 times.
✓ Branch 3 taken 12909 times.
14162 if (tempguy.attributes[8]==e9tPOLSVOICE||tempguy.attributes[8]==e9tVIRE)
15125 1253 break;
15126 [[fallthrough]];
15127 case eeOTHER:
15128 case eeSCRIPT01: case eeSCRIPT02: case eeSCRIPT03: case eeSCRIPT04: case eeSCRIPT05:
15129 case eeSCRIPT06: case eeSCRIPT07: case eeSCRIPT08: case eeSCRIPT09: case eeSCRIPT10:
15130 case eeSCRIPT11: case eeSCRIPT12: case eeSCRIPT13: case eeSCRIPT14: case eeSCRIPT15:
15131 case eeSCRIPT16: case eeSCRIPT17: case eeSCRIPT18: case eeSCRIPT19: case eeSCRIPT20:
15132 case eeFFRIENDLY01: case eeFFRIENDLY02: case eeFFRIENDLY03: case eeFFRIENDLY04: case eeFFRIENDLY05:
15133 case eeFFRIENDLY06: case eeFFRIENDLY07: case eeFFRIENDLY08: case eeFFRIENDLY09: case eeFFRIENDLY10:
15134 16055 tempguy.moveflags = move_obeys_grav | move_can_pitfall;
15135 16055 }
15136 }
15137
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 105472 times.
203776 if(guyversion < 43)
15138 {
15139
2/2
✓ Branch 0 taken 86023 times.
✓ Branch 1 taken 19449 times.
105472 switch(tempguy.family)
15140 {
15141 //No gravity; floats over pits
15142 case eeTEK: case eePEAHAT: case eeROCK: case eeTRAP:
15143 case eePROJECTILE: case eeSPINTILE: case eeKEESE: case eeFIRE:
15144 //Special (bosses, etc)
15145 case eeFAIRY: case eeGUY: case eeNONE: case eeZORA:
15146 case eeAQUA: case eeDIG: case eeGHOMA: case eeGANON:
15147 case eePATRA: case eeGLEEOK: case eeMOLD: case eeMANHAN:
15148 case eeWIZZ: case eeWALLM: case eeGHINI:
15149 //Gravity, floats over pits
15150 86023 tempguy.moveflags |= move_can_waterwalk;
15151 86023 tempguy.moveflags |= move_can_pitwalk;
15152 86023 break;
15153 }
15154 105472 }
15155
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 105472 times.
203776 if (guyversion < 44)
15156 {
15157
2/2
✓ Branch 0 taken 104536 times.
✓ Branch 1 taken 936 times.
105472 if ( tempguy.family == eeGHOMA )
15158 {
15159 936 tempguy.flags |= guy_fade_instant;
15160 936 }
15161 105472 }
15162
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 105472 times.
203776 if (guyversion > 44)
15163 {
15164
1/2
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
98304 if(!p_getc(&(tempguy.spr_shadow),f))
15165 {
15166 return qe_invalid;
15167 }
15168
1/2
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
98304 if(!p_getc(&(tempguy.spr_death),f))
15169 {
15170 return qe_invalid;
15171 }
15172
1/2
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
98304 if(!p_getc(&(tempguy.spr_spawn),f))
15173 {
15174 return qe_invalid;
15175 }
15176 98304 }
15177 else
15178 {
15179
2/2
✓ Branch 0 taken 105063 times.
✓ Branch 1 taken 409 times.
105472 tempguy.spr_shadow = (tempguy.family==eeROCK && tempguy.attributes[9]==1) ? iwLargeShadow : iwShadow;
15180 105472 tempguy.spr_death = iwDeath;
15181 105472 tempguy.spr_spawn = iwSpawn;
15182 }
15183
15184
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 105472 times.
203776 if(guyversion < 46)
15185 {
15186
4/4
✓ Branch 0 taken 14162 times.
✓ Branch 1 taken 91310 times.
✓ Branch 2 taken 13449 times.
✓ Branch 3 taken 713 times.
105472 if(tempguy.family == eeWALK && tempguy.attributes[8] == e9tPOLSVOICE)
15187 {
15188 713 tempguy.moveflags |= move_can_waterwalk;
15189 713 }
15190 105472 }
15191
15192
2/2
✓ Branch 0 taken 95744 times.
✓ Branch 1 taken 108032 times.
203776 if (guyversion < 47)
15193 {
15194
4/4
✓ Branch 0 taken 1466 times.
✓ Branch 1 taken 106566 times.
✓ Branch 2 taken 880 times.
✓ Branch 3 taken 586 times.
108032 if (tempguy.family == eeDIG && tempguy.attributes[9]!=1)
15195 {
15196 586 tempguy.flags |= guy_ignore_kill_all;
15197 586 }
15198 108032 }
15199
15200
2/2
✓ Branch 0 taken 75264 times.
✓ Branch 1 taken 128512 times.
203776 if (guyversion < 49)
15201 {
15202
8/8
✓ Branch 0 taken 16691 times.
✓ Branch 1 taken 111821 times.
✓ Branch 2 taken 16208 times.
✓ Branch 3 taken 483 times.
✓ Branch 4 taken 15714 times.
✓ Branch 5 taken 494 times.
✓ Branch 6 taken 539 times.
✓ Branch 7 taken 15175 times.
128512 if (tempguy.family == eeWALK && (tempguy.attributes[6]==e7tPERMJINX || tempguy.attributes[6]==e7tTEMPJINX || tempguy.attributes[6]==e7tUNJINX)) //BUBBLE CHECK
15203 {
15204
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 725 times.
✓ Branch 2 taken 730 times.
✓ Branch 3 taken 61 times.
1516 switch (tempguy.attributes[7]) {
15205 case 0: //Sword
15206 725 tempguy.attributes[7] = e8tSWORD;
15207 725 break;
15208 case 1: //Item
15209 730 tempguy.attributes[7] = e8tITEM;
15210 730 break;
15211 case 2: //Both
15212 61 tempguy.attributes[7] = e8tSWORD|e8tITEM;
15213 61 break;
15214 default: //this can actually happen since Misc8 can be set to any number.
15215 tempguy.attributes[7] = 0;
15216 break;
15217 }
15218 1516 }
15219 128512 }
15220
15221 //these could possible be combined but rather be safe...
15222
2/2
✓ Branch 0 taken 75264 times.
✓ Branch 1 taken 128512 times.
203776 if (guyversion < 51) //reimport the firesfx, zoria ducked up.
15223 {
15224 128512 guy_update_firesfx(tempguy);
15225 128512 }
15226
2/2
✓ Branch 0 taken 128512 times.
✓ Branch 1 taken 75264 times.
203776 if (guyversion < 52)
15227 {
15228 128512 guy_update_weaponflags(tempguy);
15229 128512 }
15230
2/2
✓ Branch 0 taken 62464 times.
✓ Branch 1 taken 12800 times.
75264 else if(guyversion < 54)
15231 {
15232
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if (!p_getc(&(tempguy.weap_data.unblockable), f))
15233 return qe_invalid;
15234
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if (!p_igetl(&(tempguy.weap_data.moveflags), f))
15235 return qe_invalid;
15236
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if (!p_igetl(&(tempguy.weap_data.override_flags), f))
15237 return qe_invalid;
15238
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if (!p_igetl(&(tempguy.weap_data.tilew), f))
15239 return qe_invalid;
15240
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if (!p_igetl(&(tempguy.weap_data.tileh), f))
15241 return qe_invalid;
15242
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if (!p_igetl(&(tempguy.weap_data.hxsz), f))
15243 return qe_invalid;
15244
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if (!p_igetl(&(tempguy.weap_data.hysz), f))
15245 return qe_invalid;
15246
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if (!p_igetl(&(tempguy.weap_data.hzsz), f))
15247 return qe_invalid;
15248
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if (!p_igetl(&(tempguy.weap_data.hxofs), f))
15249 return qe_invalid;
15250
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if (!p_igetl(&(tempguy.weap_data.hyofs), f))
15251 return qe_invalid;
15252
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if (!p_igetl(&(tempguy.weap_data.xofs), f))
15253 return qe_invalid;
15254
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if (!p_igetl(&(tempguy.weap_data.yofs), f))
15255 return qe_invalid;
15256 int32_t temp_step;
15257
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if (!p_igetl(&temp_step, f))
15258 return qe_invalid;
15259 12800 tempguy.weap_data.step = zslongToFix(temp_step*100);
15260
2/2
✓ Branch 0 taken 64000 times.
✓ Branch 1 taken 12800 times.
76800 for (int32_t q = 0; q < WPNSPR_MAX; ++q)
15261 {
15262
1/2
✓ Branch 0 taken 64000 times.
✗ Branch 1 not taken.
64000 if (!p_igetw(&(tempguy.weap_data.burnsprs[q]), f))
15263 return qe_invalid;
15264
1/2
✓ Branch 0 taken 64000 times.
✗ Branch 1 not taken.
64000 if (!p_igetw(&(tempguy.weap_data.light_rads[q]), f))
15265 return qe_invalid;
15266 64000 }
15267 12800 }
15268
2/2
✓ Branch 0 taken 128512 times.
✓ Branch 1 taken 75264 times.
203776 if (guyversion < 53)
15269 {
15270 128512 guy_update_weaponspecialsfx(tempguy);
15271 128512 }
15272 else
15273 {
15274
1/2
✓ Branch 0 taken 75264 times.
✗ Branch 1 not taken.
75264 if (!p_getc(&(tempguy.specialsfx), f))
15275 return qe_invalid;
15276 }
15277
15278
2/2
✓ Branch 0 taken 62464 times.
✓ Branch 1 taken 141312 times.
203776 if(guyversion >= 54)
15279 {
15280
1/2
✓ Branch 0 taken 62464 times.
✗ Branch 1 not taken.
62464 if(auto ret = read_weap_data(tempguy.weap_data, f))
15281 return ret;
15282 62464 }
15283 else
15284 {
15285
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 141312 times.
141312 SETFLAG(tempguy.weap_data.wflags, WFLAG_UPDATE_IGNITE_SPRITE, tempguy.flags & guy_burning_sprites);
15286 141312 tempguy.weap_data.flags |= wdata_set_step;
15287
2/2
✓ Branch 0 taken 139606 times.
✓ Branch 1 taken 1706 times.
141312 if(tempguy.weapon == ewRock)
15288 1706 tempguy.weap_data.wflags |= WFLAG_BREAK_ON_SOLID;
15289 }
15290
15291
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
15292 {
15293 tempguy.script = 0;
15294 for(int q = 0; q < 8; ++q)
15295 tempguy.initD[q] = 0;
15296 }
15297 203776 guysbuf[i] = tempguy;
15298 203776 }
15299 398 }
15300
15301 398 return 0;
15302 480 }
15303
15304 void update_guy_1(guydata *tempguy) // November 2009
15305 {
15306 bool doesntcount = false;
15307 tempguy->flags &= ~guy_weak_arrow; // Formerly 'weak to arrow' which wasn't implemented
15308
15309 switch(tempguy->family)
15310 {
15311 case 1: //eeWALK
15312 switch(tempguy->attributes[9])
15313 {
15314 case 0: //Stalfos
15315 if(tempguy->attributes[0]==1) // Fires four projectiles at once
15316 tempguy->attributes[0]=4;
15317
15318 break;
15319
15320 case 1: //Darknut
15321 goto darknuts;
15322 break;
15323 }
15324
15325 tempguy->attributes[9] = 0;
15326 break;
15327
15328 case 2: //eeSHOOT
15329 tempguy->family = eeWALK;
15330
15331 switch(tempguy->attributes[9])
15332 {
15333 case 0: //Octorok
15334 if(tempguy->attributes[0]==1||tempguy->attributes[0]==2)
15335 {
15336 tempguy->attributes[0]=e1tFIREOCTO;
15337 tempguy->attributes[1]=e2tFIREOCTO;
15338 }
15339 else tempguy->attributes[0] = 0;
15340
15341 tempguy->attributes[5]=tempguy->attributes[3];
15342 tempguy->attributes[3]=tempguy->attributes[2];
15343 tempguy->attributes[2]=0;
15344 break;
15345
15346 case 1: // Moblin
15347 tempguy->attributes[0] = 0;
15348 break;
15349
15350 case 2: //Lynel
15351 tempguy->attributes[5]=tempguy->attributes[0]+1;
15352 tempguy->attributes[0]=0;
15353 break;
15354
15355 case 3: //Stalfos 2
15356 if(tempguy->attributes[0]==1) // Fires four projectiles at once
15357 tempguy->attributes[0]=e1t4SHOTS;
15358 else tempguy->attributes[0] = 0;
15359
15360 break;
15361
15362 case 4: //Darknut 5
15363 darknuts:
15364 tempguy->defense[edefFIRE] = edIGNORE;
15365 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15366 tempguy->defense[edefHOOKSHOT] = 0;
15367 tempguy->defense[edefARROW] = tempguy->defense[edefBYRNA] = tempguy->defense[edefREFROCK] =
15368 tempguy->defense[edefMAGIC] = tempguy->defense[edefSTOMP] = edCHINK;
15369
15370 if(tempguy->attributes[0]==1)
15371 tempguy->attributes[0]=2;
15372 else if(tempguy->attributes[0]==2)
15373 {
15374 tempguy->attributes[3]=tempguy->attributes[2];
15375 tempguy->attributes[2]=tempguy->attributes[1];
15376 tempguy->attributes[1]=e2tSPLIT;
15377 tempguy->attributes[0] = 0;
15378 }
15379 else tempguy->attributes[0] = 0;
15380
15381 tempguy->flags |= guy_shield_front;
15382
15383 if(!get_bit(deprecated_rules,qr_BRKBLSHLDS_DEP))
15384 tempguy->flags &= ~guy_bkshield;
15385 else
15386 tempguy->flags |= guy_bkshield;
15387
15388 break;
15389 }
15390
15391 tempguy->attributes[9] = 0;
15392 break;
15393
15394 /*
15395 case 9: //eeARMOS
15396 tempguy->family = eeWALK;
15397 break;
15398 */
15399 case 11: //eeGEL
15400 case 33: //eeGELTRIB
15401 if(tempguy->family==33)
15402 {
15403 tempguy->attributes[3] = 1;
15404
15405 if(get_bit(deprecated_rules, qr_OLDTRIBBLES_DEP)) //Old Tribbles
15406 tempguy->attributes[2] = tempguy->attributes[1];
15407
15408 tempguy->attributes[1] = e2tTRIBBLE;
15409 }
15410 else
15411 {
15412 tempguy->attributes[3] = 0;
15413 tempguy->attributes[2] = 0;
15414 tempguy->attributes[1] = 0;
15415 }
15416
15417 tempguy->family = eeWALK;
15418
15419 if(tempguy->attributes[0])
15420 {
15421 tempguy->attributes[0]=1;
15422 tempguy->weapon = ewFireTrail;
15423 }
15424
15425 break;
15426
15427 case 34: //eeZOLTRIB
15428 case 12: //eeZOL
15429 tempguy->attributes[3]=tempguy->attributes[2];
15430 tempguy->attributes[2]=tempguy->attributes[1];
15431 tempguy->family = eeWALK;
15432 tempguy->attributes[1]=e2tSPLITHIT;
15433
15434 if(tempguy->attributes[0])
15435 {
15436 tempguy->attributes[0]=1;
15437 tempguy->weapon = ewFireTrail;
15438 }
15439
15440 break;
15441
15442 case 13: //eeROPE
15443 tempguy->family = eeWALK;
15444 tempguy->attributes[8] = e9tROPE;
15445
15446 if(tempguy->attributes[0])
15447 {
15448 tempguy->attributes[3] = tempguy->attributes[2];
15449 tempguy->attributes[2] = tempguy->attributes[1];
15450 tempguy->attributes[1] = e2tBOMBCHU;
15451 }
15452
15453 tempguy->attributes[0] = 0;
15454 break;
15455
15456 case 14: //eeGORIYA
15457 tempguy->family = eeWALK;
15458
15459 if(tempguy->attributes[0]!=2) tempguy->attributes[0] = 0;
15460
15461 break;
15462
15463 case 17: //eeBUBBLE
15464 tempguy->family = eeWALK;
15465 tempguy->attributes[7] = tempguy->attributes[1];
15466 tempguy->attributes[6] = tempguy->attributes[0] + 1;
15467 tempguy->attributes[0] = tempguy->attributes[1] = 0;
15468
15469 //fallthrogh
15470 case eeTRAP:
15471 case eeROCK:
15472 doesntcount = true;
15473 break;
15474
15475 case 35: //eeVIRETRIB
15476 case 18: //eeVIRE
15477 tempguy->family = eeWALK;
15478 tempguy->attributes[3]=tempguy->attributes[2];
15479 tempguy->attributes[2]=tempguy->attributes[1];
15480 tempguy->attributes[1]=e2tSPLITHIT;
15481 tempguy->attributes[8]=e9tVIRE;
15482 break;
15483
15484 case 19: //eeLIKE
15485 tempguy->family = eeWALK;
15486 tempguy->attributes[6] = e7tEATITEMS;
15487 tempguy->attributes[7]=95;
15488 break;
15489
15490 case 20: //eePOLSV
15491 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15492 tempguy->defense[edefBOMB] = tempguy->defense[edefSBOMB] = tempguy->defense[edefFIRE] = edIGNORE;
15493 tempguy->defense[edefMAGIC] = tempguy->defense[edefBYRNA] = edCHINK;
15494 tempguy->defense[edefARROW] = ed1HKO;
15495 tempguy->defense[edefHOOKSHOT] = edSTUNONLY;
15496 tempguy->family = eeWALK;
15497 tempguy->attributes[8] = e9tPOLSVOICE;
15498 tempguy->rate = 4;
15499 tempguy->homing = 32;
15500 tempguy->hrate = 10;
15501 tempguy->grumble = 0;
15502 break;
15503
15504 case eeWIZZ:
15505 if(tempguy->attributes[3])
15506 {
15507 for(int32_t i=0; i < edefLAST; i++)
15508 tempguy->defense[i] = (i != edefREFBEAM && i != edefREFMAGIC && i != edefQUAKE) ? edIGNORE : 0;
15509 }
15510 else
15511 {
15512 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15513 tempguy->defense[edefMAGIC] = edCHINK;
15514 tempguy->defense[edefHOOKSHOT] = edSTUNONLY;
15515 tempguy->defense[edefARROW] = tempguy->defense[edefFIRE] =
15516 tempguy->defense[edefWAND] = tempguy->defense[edefBYRNA] = edIGNORE;
15517 }
15518
15519 break;
15520
15521 case eePEAHAT:
15522 tempguy->flags &= ~(guy_superman|guy_sbombonly);
15523
15524 if(!(tempguy->flags & guy_bhit))
15525 tempguy->defense[edefBRANG] = edSTUNONLY;
15526
15527 break;
15528
15529 case eeLEV:
15530 tempguy->defense[edefSTOMP] = edCHINK;
15531 break;
15532 }
15533
15534 // Old flags
15535 if(tempguy->flags & guy_superman)
15536 {
15537 for(int32_t i = 0; i < edefLAST; i++)
15538 if(!(i==edefSBOMB && (tempguy->flags & guy_sbombonly)))
15539 tempguy->defense[i] = (i==edefBRANG && tempguy->defense[i] != edIGNORE
15540 && tempguy->family != eeROCK && tempguy->family != eeTRAP
15541 && tempguy->family != eePROJECTILE) ? edSTUNORIGNORE : edIGNORE;
15542 }
15543
15544 tempguy->flags &= ~(guy_superman|guy_sbombonly);
15545
15546 if(doesntcount)
15547 tempguy->flags |= (guy_doesnt_count);
15548 }
15549
15550 1186880 int32_t readmapscreen_old(PACKFILE *f, zquestheader *Header, mapscr *temp_mapscr, word version, int scrind)
15551 {
15552 1186880 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_maps);
15553
15554 byte tempbyte, padding;
15555 int32_t extras, secretcombos;
15556
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1186880 times.
1186880 if(!p_getc(&(temp_mapscr->valid),f))
15557 {
15558 return qe_invalid;
15559 }
15560
15561
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1186880 times.
1186880 if(!p_getc(&(temp_mapscr->guy),f))
15562 return qe_invalid;
15563 1186880 temp_mapscr->guytile = -1; //signal to use default guy values
15564
2/2
✓ Branch 0 taken 1186279 times.
✓ Branch 1 taken 601 times.
1186880 SETFLAG(temp_mapscr->roomflags,RFL_ALWAYS_GUY,temp_mapscr->guy==gFAIRY);
15565
4/4
✓ Branch 0 taken 601 times.
✓ Branch 1 taken 1186279 times.
✓ Branch 2 taken 62 times.
✓ Branch 3 taken 539 times.
1186880 SETFLAG(temp_mapscr->roomflags,RFL_GUYFIRES,temp_mapscr->guy!=gFAIRY || !get_qr(qr_NOFAIRYGUYFIRES));
15566
15567
5/6
✓ Branch 0 taken 1164704 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1161984 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1186880 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<146)))
15568 {
15569
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22176 times.
22176 if(!p_getc(&tempbyte,f))
15570 {
15571 return qe_invalid;
15572 }
15573
15574 22176 temp_mapscr->str=tempbyte;
15575 22176 }
15576 else
15577 {
15578
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1164704 times.
1164704 if(!p_igetw(&(temp_mapscr->str),f))
15579 {
15580 return qe_invalid;
15581 }
15582 }
15583
15584
1/2
✓ Branch 0 taken 1186880 times.
✗ Branch 1 not taken.
1186880 if(!p_getc(&(temp_mapscr->room),f))
15585 {
15586 return qe_invalid;
15587 }
15588
15589
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1186880 times.
1186880 if(!p_getc(&(temp_mapscr->item),f))
15590 {
15591 return qe_invalid;
15592 }
15593
15594
3/6
✓ Branch 0 taken 658376 times.
✓ Branch 1 taken 528504 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 658376 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1186880 if(Header->zelda_version < 0x211 || (Header->zelda_version == 0x211 && Header->build < 14))
15595 {
15596 528504 temp_mapscr->hasitem = (temp_mapscr->item != 0) ? 1 : 0;
15597 528504 }
15598 else
15599 {
15600
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 658376 times.
658376 if(!p_getc(&(temp_mapscr->hasitem),f))
15601 return qe_invalid;
15602 }
15603
15604
3/4
✓ Branch 0 taken 1164704 times.
✓ Branch 1 taken 22176 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2720 times.
1189600 if((Header->zelda_version < 0x192)||
15605
2/2
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1161984 times.
1164704 ((Header->zelda_version == 0x192)&&(Header->build<154)))
15606 {
15607
1/2
✓ Branch 0 taken 22176 times.
✗ Branch 1 not taken.
22176 if(!p_getc(&tempbyte,f))
15608 {
15609 return qe_invalid;
15610 }
15611 22176 }
15612
15613
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1186880 times.
1186880 if(!p_getc(&(temp_mapscr->tilewarptype[0]),f))
15614 {
15615 return qe_invalid;
15616 }
15617
15618
2/2
✓ Branch 0 taken 1161984 times.
✓ Branch 1 taken 24896 times.
1186880 if(Header->zelda_version < 0x193)
15619 {
15620
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24896 times.
24896 if(!p_getc(&tempbyte,f))
15621 {
15622 return qe_invalid;
15623 }
15624 24896 }
15625
15626
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 658376 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1186880 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15627 {
15628
2/2
✓ Branch 0 taken 1975128 times.
✓ Branch 1 taken 658376 times.
2633504 for(int32_t i=1; i<4; i++)
15629 {
15630
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1975128 times.
1975128 if(!p_getc(&(temp_mapscr->tilewarptype[i]),f))
15631 {
15632 return qe_invalid;
15633 }
15634 1975128 }
15635 658376 }
15636 else
15637 {
15638 528504 temp_mapscr->tilewarptype[1]=0;
15639 528504 temp_mapscr->tilewarptype[2]=0;
15640 528504 temp_mapscr->tilewarptype[3]=0;
15641 }
15642
15643
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1161984 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1186880 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
15644 {
15645
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1164704 times.
1164704 if(!p_igetw(&(temp_mapscr->door_combo_set),f))
15646 {
15647 return qe_invalid;
15648 }
15649 1164704 }
15650
15651
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1186880 times.
1186880 if(!p_getc(&(temp_mapscr->warpreturnx[0]),f))
15652 {
15653 return qe_invalid;
15654 }
15655
15656 1186880 temp_mapscr->warpreturnx[1]=0;
15657 1186880 temp_mapscr->warpreturnx[2]=0;
15658 1186880 temp_mapscr->warpreturnx[3]=0;
15659
15660
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 658376 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1186880 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15661 {
15662
2/2
✓ Branch 0 taken 1975128 times.
✓ Branch 1 taken 658376 times.
2633504 for(int32_t i=1; i<4; i++)
15663 {
15664
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1975128 times.
1975128 if(!p_getc(&(temp_mapscr->warpreturnx[i]),f))
15665 {
15666 return qe_invalid;
15667 }
15668 1975128 }
15669 658376 }
15670
15671
1/2
✓ Branch 0 taken 1186880 times.
✗ Branch 1 not taken.
1186880 if(!p_getc(&(temp_mapscr->warpreturny[0]),f))
15672 {
15673 return qe_invalid;
15674 }
15675
15676 1186880 temp_mapscr->warpreturny[1]=0;
15677 1186880 temp_mapscr->warpreturny[2]=0;
15678 1186880 temp_mapscr->warpreturny[3]=0;
15679
15680
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 658376 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1186880 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15681 {
15682
2/2
✓ Branch 0 taken 1975128 times.
✓ Branch 1 taken 658376 times.
2633504 for(int32_t i=1; i<4; i++)
15683 {
15684
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1975128 times.
1975128 if(!p_getc(&(temp_mapscr->warpreturny[i]),f))
15685 {
15686 return qe_invalid;
15687 }
15688 1975128 }
15689
15690
1/2
✓ Branch 0 taken 658376 times.
✗ Branch 1 not taken.
658376 if(version>=18)
15691 {
15692
1/2
✓ Branch 0 taken 658376 times.
✗ Branch 1 not taken.
658376 if(!p_igetw(&temp_mapscr->warpreturnc,f))
15693 {
15694 return qe_invalid;
15695 }
15696 658376 }
15697 else
15698 {
15699 byte temp;
15700
15701 if(!p_getc(&temp,f))
15702 {
15703 return qe_invalid;
15704 }
15705
15706 temp_mapscr->warpreturnc=temp<<8|temp;
15707 }
15708 658376 }
15709
15710
1/2
✓ Branch 0 taken 1186880 times.
✗ Branch 1 not taken.
1186880 if(!p_getc(&(temp_mapscr->stairx),f))
15711
15712 {
15713 return qe_invalid;
15714 }
15715
15716
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1186880 times.
1186880 if(!p_getc(&(temp_mapscr->stairy),f))
15717 {
15718 return qe_invalid;
15719 }
15720
15721
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1186880 times.
1186880 if(!p_getc(&(temp_mapscr->itemx),f))
15722 {
15723 return qe_invalid;
15724 }
15725
15726
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1186880 times.
1186880 if(!p_getc(&(temp_mapscr->itemy),f))
15727 {
15728 return qe_invalid;
15729 }
15730
15731
2/2
✓ Branch 0 taken 658376 times.
✓ Branch 1 taken 528504 times.
1186880 if(version > 15) // February 2009
15732 {
15733
1/2
✓ Branch 0 taken 658376 times.
✗ Branch 1 not taken.
658376 if(!p_igetw(&(temp_mapscr->color),f))
15734 {
15735 return qe_invalid;
15736 }
15737 658376 }
15738 else
15739 {
15740
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 528504 times.
528504 if(!p_getc(& tempbyte,f))
15741 {
15742 return qe_invalid;
15743 }
15744
15745 528504 temp_mapscr->color = (word) tempbyte;
15746 }
15747
15748
1/2
✓ Branch 0 taken 1186880 times.
✗ Branch 1 not taken.
1186880 if(!p_getc(&(temp_mapscr->flags11),f))
15749 {
15750 return qe_invalid;
15751 }
15752
15753
2/2
✓ Branch 0 taken 4747520 times.
✓ Branch 1 taken 1186880 times.
5934400 for(int32_t k=0; k<4; k++)
15754 {
15755
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4747520 times.
4747520 if(!p_getc(&(temp_mapscr->door[k]),f))
15756 {
15757 return qe_invalid;
15758
15759 }
15760 4747520 }
15761
15762
2/2
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 658376 times.
1186880 if(version <= 11)
15763 {
15764
1/2
✓ Branch 0 taken 528504 times.
✗ Branch 1 not taken.
528504 if(!p_getc(&(tempbyte),f))
15765 {
15766 return qe_invalid;
15767 }
15768
15769 528504 temp_mapscr->tilewarpdmap[0]=(word)tempbyte;
15770
15771
2/6
✓ Branch 0 taken 528504 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
528504 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15772 {
15773 for(int32_t i=1; i<4; i++)
15774 {
15775 if(!p_getc(&(tempbyte),f))
15776 {
15777 return qe_invalid;
15778 }
15779
15780 temp_mapscr->tilewarpdmap[i]=(word)tempbyte;
15781 }
15782 }
15783 else
15784 {
15785 528504 temp_mapscr->tilewarpdmap[1]=0;
15786 528504 temp_mapscr->tilewarpdmap[2]=0;
15787 528504 temp_mapscr->tilewarpdmap[3]=0;
15788 }
15789 528504 }
15790 else
15791 {
15792
2/2
✓ Branch 0 taken 2633504 times.
✓ Branch 1 taken 658376 times.
3291880 for(int32_t i=0; i<4; i++)
15793 {
15794
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2633504 times.
2633504 if(!p_igetw(&(temp_mapscr->tilewarpdmap[i]),f))
15795 {
15796 return qe_invalid;
15797 }
15798 2633504 }
15799 }
15800
15801
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1186880 times.
1186880 if(!p_getc(&(temp_mapscr->tilewarpscr[0]),f))
15802 {
15803 return qe_invalid;
15804 }
15805
15806
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 658376 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1186880 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15807 {
15808
2/2
✓ Branch 0 taken 1975128 times.
✓ Branch 1 taken 658376 times.
2633504 for(int32_t i=1; i<4; i++)
15809 {
15810
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1975128 times.
1975128 if(!p_getc(&(temp_mapscr->tilewarpscr[i]),f))
15811 {
15812 return qe_invalid;
15813 }
15814 1975128 }
15815 658376 }
15816 else
15817 {
15818 528504 temp_mapscr->tilewarpscr[1]=0;
15819 528504 temp_mapscr->tilewarpscr[2]=0;
15820 528504 temp_mapscr->tilewarpscr[3]=0;
15821 }
15822
15823
2/2
✓ Branch 0 taken 658376 times.
✓ Branch 1 taken 528504 times.
1186880 if(version >= 15)
15824 {
15825
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 658376 times.
658376 if(!p_getc(&(temp_mapscr->tilewarpoverlayflags),f))
15826 {
15827 return qe_invalid;
15828 }
15829 658376 }
15830 else
15831 {
15832 528504 temp_mapscr->tilewarpoverlayflags=0;
15833 }
15834
15835
1/2
✓ Branch 0 taken 1186880 times.
✗ Branch 1 not taken.
1186880 if(!p_getc(&(temp_mapscr->exitdir),f))
15836 {
15837 return qe_invalid;
15838 }
15839
15840
2/2
✓ Branch 0 taken 1161984 times.
✓ Branch 1 taken 24896 times.
1186880 if(Header->zelda_version < 0x193)
15841 {
15842
1/2
✓ Branch 0 taken 24896 times.
✗ Branch 1 not taken.
24896 if(!p_getc(&tempbyte,f))
15843 {
15844 return qe_invalid;
15845 }
15846
15847 24896 }
15848
15849
4/6
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1184160 times.
✓ Branch 2 taken 2720 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1186880 if((Header->zelda_version == 0x192)&&(Header->build>145)&&(Header->build<154))
15850 {
15851 if(!p_getc(&padding,f))
15852 {
15853 return qe_invalid;
15854 }
15855 }
15856
15857
2/2
✓ Branch 0 taken 11868800 times.
✓ Branch 1 taken 1186880 times.
13055680 for(int32_t k=0; k<10; k++)
15858 {
15859
5/6
✓ Branch 0 taken 11647040 times.
✓ Branch 1 taken 221760 times.
✓ Branch 2 taken 27200 times.
✓ Branch 3 taken 11619840 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 27200 times.
11868800 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<10)))
15860 {
15861
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 221760 times.
221760 if(!p_getc(&tempbyte,f))
15862 {
15863 return qe_invalid;
15864 }
15865
15866 221760 temp_mapscr->enemy[k]=tempbyte;
15867
15868 // 76 is the highest enemy id possible to set in 1.90. Anything higher must have come
15869 // from corrupting when 1.90 saved the quest.
15870 // https://discord.com/channels/876899628556091432/1287580827164737658
15871
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 221760 times.
221760 if (Header->zelda_version <= 0x190)
15872 {
15873
1/2
✓ Branch 0 taken 221760 times.
✗ Branch 1 not taken.
221760 if (temp_mapscr->enemy[k] > 76)
15874 {
15875 temp_mapscr->enemy[k] = 0;
15876 }
15877 221760 }
15878 221760 }
15879 else
15880 {
15881
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11647040 times.
11647040 if(!p_igetw(&(temp_mapscr->enemy[k]),f))
15882 {
15883 return qe_invalid;
15884 }
15885 }
15886
15887
5/6
✓ Branch 0 taken 11647040 times.
✓ Branch 1 taken 221760 times.
✓ Branch 2 taken 27200 times.
✓ Branch 3 taken 11619840 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 27200 times.
11868800 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<108)))
15888 {
15889 //using enumerations here is dangerous
15890 //very easy to break old quests -DD
15891
2/2
✓ Branch 0 taken 1342 times.
✓ Branch 1 taken 220418 times.
221760 if(temp_mapscr->enemy[k]>=57) //old eGOHMA1
15892 {
15893 1342 temp_mapscr->enemy[k]+=5;
15894 1342 }
15895
2/2
✓ Branch 0 taken 220324 times.
✓ Branch 1 taken 94 times.
220418 else if(temp_mapscr->enemy[k]>=52) //old eGLEEOK2
15896 {
15897 94 temp_mapscr->enemy[k]+=1;
15898 94 }
15899 221760 }
15900
15901
2/2
✓ Branch 0 taken 6583760 times.
✓ Branch 1 taken 5285040 times.
11868800 if(version < 9)
15902 {
15903
2/2
✓ Branch 0 taken 5009135 times.
✓ Branch 1 taken 275905 times.
5285040 if(temp_mapscr->enemy[k]>0)
15904 {
15905 275905 temp_mapscr->enemy[k]+=10;
15906 275905 }
15907 5285040 }
15908 //don't read in any invalid data
15909
2/2
✓ Branch 0 taken 11868350 times.
✓ Branch 1 taken 450 times.
11868800 if ( ((unsigned)temp_mapscr->enemy[k]) > MAXGUYS )
15910 {
15911 450 al_trace("Tried to read an invalid enemy ID (%d) for enemy[%d]. This has been cleared to 0.\n", temp_mapscr->enemy[k], k);
15912 450 temp_mapscr->enemy[k] = 0;
15913 450 }
15914 11868800 }
15915
15916
1/2
✓ Branch 0 taken 1186880 times.
✗ Branch 1 not taken.
1186880 if(!p_getc(&(temp_mapscr->pattern),f))
15917 {
15918 return qe_invalid;
15919 }
15920
15921
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1186880 times.
1186880 if(!p_getc(&(temp_mapscr->sidewarptype[0]),f))
15922 {
15923 return qe_invalid;
15924 }
15925
15926
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 658376 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1186880 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15927 {
15928
2/2
✓ Branch 0 taken 1975128 times.
✓ Branch 1 taken 658376 times.
2633504 for(int32_t i=1; i<4; i++)
15929 {
15930
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1975128 times.
1975128 if(!p_getc(&(temp_mapscr->sidewarptype[i]),f))
15931 {
15932 return qe_invalid;
15933 }
15934 1975128 }
15935 658376 }
15936 else
15937 {
15938 528504 temp_mapscr->sidewarptype[1]=0;
15939 528504 temp_mapscr->sidewarptype[2]=0;
15940 528504 temp_mapscr->sidewarptype[3]=0;
15941 }
15942
15943
2/2
✓ Branch 0 taken 658376 times.
✓ Branch 1 taken 528504 times.
1186880 if(version >= 15)
15944 {
15945
1/2
✓ Branch 0 taken 658376 times.
✗ Branch 1 not taken.
658376 if(!p_getc(&(temp_mapscr->sidewarpoverlayflags),f))
15946 {
15947 return qe_invalid;
15948 }
15949 658376 }
15950 else
15951 {
15952 528504 temp_mapscr->sidewarpoverlayflags=0;
15953 }
15954
15955
1/2
✓ Branch 0 taken 1186880 times.
✗ Branch 1 not taken.
1186880 if(!p_getc(&(temp_mapscr->warparrivalx),f))
15956 {
15957 return qe_invalid;
15958 }
15959
15960
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1186880 times.
1186880 if(!p_getc(&(temp_mapscr->warparrivaly),f))
15961 {
15962 return qe_invalid;
15963 }
15964
15965
2/2
✓ Branch 0 taken 4747520 times.
✓ Branch 1 taken 1186880 times.
5934400 for(int32_t k=0; k<4; k++)
15966 {
15967
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4747520 times.
4747520 if(!p_getc(&(temp_mapscr->path[k]),f))
15968 {
15969 return qe_invalid;
15970 }
15971 4747520 }
15972
15973
1/2
✓ Branch 0 taken 1186880 times.
✗ Branch 1 not taken.
1186880 if(!p_getc(&(temp_mapscr->sidewarpscr[0]),f))
15974 {
15975 return qe_invalid;
15976 }
15977
15978
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 658376 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1186880 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15979 {
15980
2/2
✓ Branch 0 taken 658376 times.
✓ Branch 1 taken 1975128 times.
2633504 for(int32_t i=1; i<4; i++)
15981 {
15982
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1975128 times.
1975128 if(!p_getc(&(temp_mapscr->sidewarpscr[i]),f))
15983 {
15984 return qe_invalid;
15985 }
15986 1975128 }
15987 658376 }
15988 else
15989 {
15990 528504 temp_mapscr->sidewarpscr[1]=0;
15991 528504 temp_mapscr->sidewarpscr[2]=0;
15992 528504 temp_mapscr->sidewarpscr[3]=0;
15993 }
15994
15995
2/2
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 658376 times.
1186880 if(version <= 11)
15996 {
15997
1/2
✓ Branch 0 taken 528504 times.
✗ Branch 1 not taken.
528504 if(!p_getc(&(tempbyte),f))
15998 {
15999 return qe_invalid;
16000 }
16001
16002 528504 temp_mapscr->sidewarpdmap[0]=(word)tempbyte;
16003
16004
2/6
✓ Branch 0 taken 528504 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
528504 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
16005 {
16006 for(int32_t i=1; i<4; i++)
16007 {
16008 if(!p_getc(&(tempbyte),f))
16009 {
16010 return qe_invalid;
16011 }
16012
16013 temp_mapscr->sidewarpdmap[i]=(word)tempbyte;
16014 }
16015 }
16016 else
16017 {
16018 528504 temp_mapscr->sidewarpdmap[1]=0;
16019 528504 temp_mapscr->sidewarpdmap[2]=0;
16020 528504 temp_mapscr->sidewarpdmap[3]=0;
16021 }
16022 528504 }
16023 else
16024 {
16025
2/2
✓ Branch 0 taken 2633504 times.
✓ Branch 1 taken 658376 times.
3291880 for(int32_t i=0; i<4; i++)
16026 {
16027
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2633504 times.
2633504 if(!p_igetw(&(temp_mapscr->sidewarpdmap[i]),f))
16028 {
16029 return qe_invalid;
16030 }
16031 2633504 }
16032 }
16033
16034
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 658376 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1186880 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
16035 {
16036
1/2
✓ Branch 0 taken 658376 times.
✗ Branch 1 not taken.
658376 if(!p_getc(&(temp_mapscr->sidewarpindex),f))
16037 {
16038 return qe_invalid;
16039 }
16040 658376 }
16041 528504 else temp_mapscr->sidewarpindex = 0;
16042
16043
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1186880 times.
1186880 if(!p_igetw(&(temp_mapscr->undercombo),f))
16044 {
16045 return qe_invalid;
16046 }
16047
16048 1186880 byte old_combo_page = 0;
16049
2/2
✓ Branch 0 taken 1161984 times.
✓ Branch 1 taken 24896 times.
1186880 if(Header->zelda_version < 0x193)
16050 {
16051
1/2
✓ Branch 0 taken 24896 times.
✗ Branch 1 not taken.
24896 if (!p_getc(&old_combo_page, f))
16052 {
16053 return qe_invalid;
16054 }
16055
16056
2/2
✓ Branch 0 taken 272 times.
✓ Branch 1 taken 24624 times.
24896 if (!should_skip)
16057 {
16058 24624 old_combo_pages[scrind] = old_combo_page;
16059 24624 }
16060 24896 }
16061
16062
1/2
✓ Branch 0 taken 1186880 times.
✗ Branch 1 not taken.
1186880 if(!p_getc(&(temp_mapscr->undercset),f)) //recalculated for older quests
16063 {
16064 return qe_invalid;
16065 }
16066
16067
1/2
✓ Branch 0 taken 1186880 times.
✗ Branch 1 not taken.
1186880 if(!p_igetw(&(temp_mapscr->catchall),f))
16068 {
16069 return qe_invalid;
16070 }
16071
16072
1/2
✓ Branch 0 taken 1186880 times.
✗ Branch 1 not taken.
1186880 if(!p_getc(&(temp_mapscr->flags),f))
16073 {
16074 return qe_invalid;
16075 }
16076
16077
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1186880 times.
1186880 if(!p_getc(&(temp_mapscr->flags2),f))
16078 {
16079 return qe_invalid;
16080 }
16081
16082
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1186880 times.
1186880 if(!p_getc(&(temp_mapscr->flags3),f))
16083 {
16084 return qe_invalid;
16085 }
16086
16087
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 658376 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1186880 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>1)))
16088 //if (version>2)
16089 {
16090
1/2
✓ Branch 0 taken 658376 times.
✗ Branch 1 not taken.
658376 if(!p_getc(&(temp_mapscr->flags4),f))
16091 {
16092 return qe_invalid;
16093 }
16094 658376 }
16095
16096
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 658376 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1186880 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
16097 {
16098
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 658376 times.
658376 if(!p_getc(&(temp_mapscr->flags5),f))
16099 {
16100 return qe_invalid;
16101 }
16102
16103
1/2
✓ Branch 0 taken 658376 times.
✗ Branch 1 not taken.
658376 if(!p_igetw(&(temp_mapscr->noreset),f))
16104 {
16105 return qe_invalid;
16106 }
16107
16108
1/2
✓ Branch 0 taken 658376 times.
✗ Branch 1 not taken.
658376 if(!p_igetw(&(temp_mapscr->nocarry),f))
16109 {
16110 return qe_invalid;
16111 }
16112
16113
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 658376 times.
658376 if(temp_mapscr->flags5&32)
16114 {
16115 temp_mapscr->flags5 &= ~32;
16116 temp_mapscr->noreset |= 48;
16117 }
16118
16119
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 658376 times.
658376 if(version<8)
16120 {
16121 if(temp_mapscr->noreset&1)
16122 {
16123 temp_mapscr->noreset|=8192;
16124 }
16125
16126 if(temp_mapscr->nocarry&1)
16127 {
16128 temp_mapscr->nocarry|=8192;
16129 temp_mapscr->nocarry&=~1;
16130 }
16131 }
16132 658376 }
16133 else
16134 {
16135 528504 temp_mapscr->flags5 = 0;
16136 528504 temp_mapscr->noreset = 0;
16137 528504 temp_mapscr->nocarry = 0;
16138 }
16139
16140
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 658376 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1186880 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>9)))
16141 {
16142
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 658376 times.
658376 if(!p_getc(&(temp_mapscr->flags6),f))
16143 {
16144 return qe_invalid;
16145 }
16146 658376 }
16147
16148
2/2
✓ Branch 0 taken 658376 times.
✓ Branch 1 taken 528504 times.
1186880 if(version>5)
16149 {
16150
1/2
✓ Branch 0 taken 658376 times.
✗ Branch 1 not taken.
658376 if(!p_getc(&(temp_mapscr->flags7),f))
16151 {
16152 return qe_invalid;
16153 }
16154
16155
1/2
✓ Branch 0 taken 658376 times.
✗ Branch 1 not taken.
658376 if(!p_getc(&(temp_mapscr->flags8),f))
16156 {
16157 return qe_invalid;
16158 }
16159
16160
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 658376 times.
658376 if(!p_getc(&(temp_mapscr->flags9),f))
16161 {
16162 return qe_invalid;
16163 }
16164
16165
1/2
✓ Branch 0 taken 658376 times.
✗ Branch 1 not taken.
658376 if(!p_getc(&(temp_mapscr->flags10),f))
16166 {
16167 return qe_invalid;
16168 }
16169
16170
1/2
✓ Branch 0 taken 658376 times.
✗ Branch 1 not taken.
658376 if(!p_getc(&(temp_mapscr->csensitive),f))
16171 {
16172 return qe_invalid;
16173 }
16174 658376 }
16175 else
16176 {
16177 528504 temp_mapscr->csensitive=1;
16178 }
16179
16180
2/2
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 658376 times.
1186880 if(version<14) // August 2007: screen SFX added
16181 {
16182
2/2
✓ Branch 0 taken 527510 times.
✓ Branch 1 taken 994 times.
528504 if(temp_mapscr->flags&8) //fROAR
16183 {
16184 994 temp_mapscr->bosssfx=
16185
2/2
✓ Branch 0 taken 141 times.
✓ Branch 1 taken 853 times.
994 (temp_mapscr->flags3&2) ? WAV_DODONGO : // fDODONGO
16186 853 (temp_mapscr->flags2&32) ? WAV_VADER : // fVADER
16187 WAV_ROAR;
16188 994 }
16189
16190
2/2
✓ Branch 0 taken 170 times.
✓ Branch 1 taken 528334 times.
528504 if(temp_mapscr->flags&128) //fSEA_SFX
16191 {
16192 170 temp_mapscr->oceansfx=WAV_SEA;
16193 170 }
16194
16195 528504 temp_mapscr->secretsfx = (temp_mapscr->flags3&64) //fNOSECRETSOUND
16196 ? 0 : WAV_SECRET;
16197
16198 528504 temp_mapscr->flags3 &= ~66; //64|2
16199 528504 temp_mapscr->flags2 &= ~32;
16200 528504 temp_mapscr->flags &= ~136; // 128|8
16201 528504 }
16202 else
16203 {
16204
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 658376 times.
658376 if(!p_getc(&(temp_mapscr->oceansfx),f))
16205 {
16206 return qe_invalid;
16207 }
16208
16209
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 658376 times.
658376 if(!p_getc(&(temp_mapscr->bosssfx),f))
16210 {
16211 return qe_invalid;
16212 }
16213
16214
1/2
✓ Branch 0 taken 658376 times.
✗ Branch 1 not taken.
658376 if(!p_getc(&(temp_mapscr->secretsfx),f))
16215 {
16216 return qe_invalid;
16217 }
16218 }
16219
16220
2/2
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 658376 times.
1186880 if(version<15) // October 2007: another SFX
16221 {
16222 528504 temp_mapscr->holdupsfx=WAV_PICKUP;
16223 528504 }
16224 else
16225 {
16226
1/2
✓ Branch 0 taken 658376 times.
✗ Branch 1 not taken.
658376 if(!p_getc(&(temp_mapscr->holdupsfx),f))
16227 {
16228 return qe_invalid;
16229 }
16230 }
16231
16232
16233
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1161984 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1186880 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>97)))
16234 {
16235
2/2
✓ Branch 0 taken 6988224 times.
✓ Branch 1 taken 1164704 times.
8152928 for(int32_t k=0; k<6; k++)
16236 {
16237
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6988224 times.
6988224 if(!p_getc(&(temp_mapscr->layermap[k]),f))
16238 {
16239 return qe_invalid;
16240 }
16241 6988224 }
16242
16243
2/2
✓ Branch 0 taken 1164704 times.
✓ Branch 1 taken 6988224 times.
8152928 for(int32_t k=0; k<6; k++)
16244 {
16245
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6988224 times.
6988224 if(!p_getc(&(temp_mapscr->layerscreen[k]),f))
16246 {
16247 return qe_invalid;
16248 }
16249 6988224 }
16250 1164704 }
16251
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 22176 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
22176 else if((Header->zelda_version == 0x192)&&(Header->build>23)&&(Header->build<98))
16252 {
16253 if(!p_getc(&(temp_mapscr->layermap[2]),f))
16254 {
16255 return qe_invalid;
16256 }
16257
16258 if(!p_getc(&(temp_mapscr->layerscreen[2]),f))
16259 {
16260 return qe_invalid;
16261 }
16262
16263 if(!p_getc(&(temp_mapscr->layermap[4]),f))
16264 {
16265 return qe_invalid;
16266 }
16267
16268 if(!p_getc(&(temp_mapscr->layerscreen[4]),f))
16269
16270 {
16271 return qe_invalid;
16272 }
16273 }
16274
16275
3/4
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1184160 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2720 times.
1186880 if((Header->zelda_version == 0x192)&&(Header->build>149))
16276 {
16277
2/2
✓ Branch 0 taken 16320 times.
✓ Branch 1 taken 2720 times.
19040 for(int32_t k=0; k<6; k++)
16278 {
16279
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16320 times.
16320 if(!p_getc(&tempbyte,f)) //layerxsize
16280 {
16281 return qe_invalid;
16282 }
16283 16320 }
16284
16285
2/2
✓ Branch 0 taken 16320 times.
✓ Branch 1 taken 2720 times.
19040 for(int32_t k=0; k<6; k++)
16286 {
16287
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16320 times.
16320 if(!p_getc(&tempbyte,f)) //layerxspeed
16288 {
16289 return qe_invalid;
16290 }
16291 16320 }
16292
16293
2/2
✓ Branch 0 taken 16320 times.
✓ Branch 1 taken 2720 times.
19040 for(int32_t k=0; k<6; k++)
16294 {
16295
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16320 times.
16320 if(!p_getc(&tempbyte,f)) //layerxdelay
16296 {
16297 return qe_invalid;
16298 }
16299 16320 }
16300
16301
2/2
✓ Branch 0 taken 16320 times.
✓ Branch 1 taken 2720 times.
19040 for(int32_t k=0; k<6; k++)
16302 {
16303
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16320 times.
16320 if(!p_getc(&tempbyte,f)) //layerysize
16304 {
16305 return qe_invalid;
16306 }
16307 16320 }
16308
16309
2/2
✓ Branch 0 taken 16320 times.
✓ Branch 1 taken 2720 times.
19040 for(int32_t k=0; k<6; k++)
16310 {
16311
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16320 times.
16320 if(!p_getc(&tempbyte,f)) //layeryspeed
16312 {
16313 return qe_invalid;
16314 }
16315 16320 }
16316
16317
2/2
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 16320 times.
19040 for(int32_t k=0; k<6; k++)
16318 {
16319
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16320 times.
16320 if(!p_getc(&tempbyte,f)) //layerydelay
16320 {
16321 return qe_invalid;
16322 }
16323 16320 }
16324 2720 }
16325
16326
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1161984 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1186880 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>149)))
16327 {
16328
2/2
✓ Branch 0 taken 6988224 times.
✓ Branch 1 taken 1164704 times.
8152928 for(int32_t k=0; k<6; k++)
16329 {
16330
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6988224 times.
6988224 if(!p_getc(&(temp_mapscr->layeropacity[k]),f))
16331 {
16332 return qe_invalid;
16333 }
16334 6988224 }
16335 1164704 }
16336
16337
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1161984 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1186880 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
16338 {
16339
3/4
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1161984 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2720 times.
1164704 if((Header->zelda_version == 0x192)&&(Header->build>153))
16340 {
16341
1/2
✓ Branch 0 taken 2720 times.
✗ Branch 1 not taken.
2720 if(!p_getc(&padding,f))
16342 {
16343 return qe_invalid;
16344 }
16345 2720 }
16346
16347
1/2
✓ Branch 0 taken 1164704 times.
✗ Branch 1 not taken.
1164704 if(!p_igetw(&(temp_mapscr->timedwarptics),f))
16348 {
16349 return qe_invalid;
16350 }
16351 1164704 }
16352
16353
5/6
✓ Branch 0 taken 1164704 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1161984 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1186880 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<24)))
16354 {
16355 22176 extras=15;
16356 22176 }
16357
3/4
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1161984 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2720 times.
1164704 else if(((Header->zelda_version == 0x192)&&(Header->build<98)))
16358 {
16359 extras=11;
16360 }
16361
3/4
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1161984 times.
✓ Branch 2 taken 2720 times.
✗ Branch 3 not taken.
1164704 else if((Header->zelda_version == 0x192)&&(Header->build<150))
16362 {
16363 extras=32;
16364 }
16365
3/4
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1161984 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2720 times.
1164704 else if((Header->zelda_version == 0x192)&&(Header->build<154))
16366 {
16367 extras=64;
16368 }
16369
2/2
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1161984 times.
1164704 else if(Header->zelda_version < 0x193)
16370 {
16371 2720 extras=62;
16372 2720 }
16373 else
16374
16375 {
16376 1161984 extras=0;
16377 }
16378
16379
2/2
✓ Branch 0 taken 501280 times.
✓ Branch 1 taken 1186880 times.
1688160 for(int32_t k=0; k<extras; k++)
16380 {
16381
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 501280 times.
501280 if(!p_getc(&tempbyte,f)) //extra[k]
16382 {
16383 return qe_invalid;
16384 }
16385 501280 }
16386
16387
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 658376 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1186880 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>2)))
16388 //if (version>3)
16389 {
16390
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 658376 times.
658376 if(!p_getc(&(temp_mapscr->nextmap),f))
16391 {
16392 return qe_invalid;
16393 }
16394
16395
1/2
✓ Branch 0 taken 658376 times.
✗ Branch 1 not taken.
658376 if(!p_getc(&(temp_mapscr->nextscr),f))
16396 {
16397 return qe_invalid;
16398 }
16399 658376 }
16400 else
16401 {
16402 528504 temp_mapscr->nextmap=0;
16403 528504 temp_mapscr->nextscr=0;
16404 }
16405
16406
5/6
✓ Branch 0 taken 1164704 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1161984 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1186880 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
16407 {
16408 22176 secretcombos=20;
16409 22176 }
16410
3/4
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1161984 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2720 times.
1164704 else if((Header->zelda_version == 0x192)&&(Header->build<154))
16411 {
16412 secretcombos=256;
16413 }
16414 else
16415 {
16416 1164704 secretcombos=128;
16417 }
16418
16419
5/6
✓ Branch 0 taken 1164704 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1161984 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1186880 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16420 {
16421
2/2
✓ Branch 0 taken 443520 times.
✓ Branch 1 taken 22176 times.
465696 for(int32_t k=0; k<secretcombos; k++)
16422 {
16423
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 443520 times.
443520 if(!p_getc(&tempbyte,f))
16424 {
16425 return qe_invalid;
16426 }
16427
16428
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 443520 times.
443520 if(k<128)
16429 {
16430 443520 temp_mapscr->secretcombo[k]=tempbyte;
16431 443520 }
16432 443520 }
16433 22176 }
16434 else
16435 {
16436
2/2
✓ Branch 0 taken 149082112 times.
✓ Branch 1 taken 1164704 times.
150246816 for(int32_t k=0; k<128; k++)
16437 {
16438
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 149082112 times.
149082112 if(!p_igetw(&(temp_mapscr->secretcombo[k]),f))
16439 {
16440 return qe_invalid;
16441 }
16442
16443 149082112 }
16444 }
16445
16446
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1161984 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1186880 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
16447 {
16448
2/2
✓ Branch 0 taken 149082112 times.
✓ Branch 1 taken 1164704 times.
150246816 for(int32_t k=0; k<128; k++)
16449 {
16450
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 149082112 times.
149082112 if(!p_getc(&(temp_mapscr->secretcset[k]),f))
16451 {
16452 return qe_invalid;
16453 }
16454 149082112 }
16455
16456
2/2
✓ Branch 0 taken 149082112 times.
✓ Branch 1 taken 1164704 times.
150246816 for(int32_t k=0; k<128; k++)
16457 {
16458
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 149082112 times.
149082112 if(!p_getc(&(temp_mapscr->secretflag[k]),f))
16459 {
16460 return qe_invalid;
16461 }
16462 149082112 }
16463 1164704 }
16464
16465
4/6
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1184160 times.
✓ Branch 2 taken 2720 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1186880 if((Header->zelda_version == 0x192)&&(Header->build>97)&&(Header->build<154))
16466 {
16467 if(!p_getc(&padding,f))
16468 {
16469 return qe_invalid;
16470 }
16471 }
16472
16473
2/2
✓ Branch 0 taken 208890880 times.
✓ Branch 1 taken 1186880 times.
210077760 for(int32_t k=0; k<176; k++)
16474 {
16475
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 208890880 times.
208890880 if(!p_igetw(&(temp_mapscr->data[k]),f))
16476 {
16477 return qe_invalid;
16478 }
16479 208890880 }
16480
16481
4/6
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1184160 times.
✓ Branch 2 taken 2720 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1186880 if((Header->zelda_version == 0x192)&&(Header->build>20)&&(Header->build<24))
16482 {
16483 if(!p_getc(&padding,f))
16484 {
16485 return qe_invalid;
16486 }
16487
16488 if(!p_getc(&padding,f))
16489 {
16490 return qe_invalid;
16491 }
16492 }
16493
16494
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1161984 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1186880 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>20)))
16495 {
16496
2/2
✓ Branch 0 taken 204987904 times.
✓ Branch 1 taken 1164704 times.
206152608 for(int32_t k=0; k<176; k++)
16497 {
16498
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 204987904 times.
204987904 if(!p_getc(&(temp_mapscr->sflag[k]),f))
16499 {
16500 return qe_invalid;
16501 }
16502
16503
3/4
✓ Branch 0 taken 478720 times.
✓ Branch 1 taken 204509184 times.
✓ Branch 2 taken 478720 times.
✗ Branch 3 not taken.
204987904 if((Header->zelda_version == 0x192)&&(Header->build<24))
16504 {
16505 if(!p_getc(&tempbyte,f))
16506 {
16507 return qe_invalid;
16508 }
16509
16510 if(!p_getc(&tempbyte,f))
16511 {
16512 return qe_invalid;
16513 }
16514
16515 if(!p_getc(&tempbyte,f))
16516 {
16517 return qe_invalid;
16518 }
16519 }
16520 204987904 }
16521 1164704 }
16522
16523
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1161984 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1186880 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>97)))
16524 {
16525
2/2
✓ Branch 0 taken 1164704 times.
✓ Branch 1 taken 204987904 times.
206152608 for(int32_t k=0; k<176; k++)
16526 {
16527
16528
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 204987904 times.
204987904 if(!p_getc(&(temp_mapscr->cset[k]),f))
16529 {
16530 return qe_invalid;
16531 }
16532 204987904 }
16533 1164704 }
16534
16535
5/6
✓ Branch 0 taken 1164704 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1161984 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1186880 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16536 {
16537 22176 temp_mapscr->undercset=(temp_mapscr->undercombo>>8)&7;
16538 22176 temp_mapscr->undercombo=(temp_mapscr->undercombo&0xFF)+(old_combo_page<<8);
16539 22176 }
16540
16541
5/6
✓ Branch 0 taken 1164704 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1161984 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1186880 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
16542 {
16543 22176 temp_mapscr->secretcombo[sSBOMB]=temp_mapscr->secretcombo[sBOMB];
16544 22176 temp_mapscr->secretcombo[sRCANDLE]=temp_mapscr->secretcombo[sBCANDLE];
16545 22176 temp_mapscr->secretcombo[sWANDFIRE]=temp_mapscr->secretcombo[sBCANDLE];
16546 22176 temp_mapscr->secretcombo[sDIVINEFIRE]=temp_mapscr->secretcombo[sBCANDLE];
16547 22176 temp_mapscr->secretcombo[sSARROW]=temp_mapscr->secretcombo[sARROW];
16548 22176 temp_mapscr->secretcombo[sGARROW]=temp_mapscr->secretcombo[sARROW];
16549 22176 }
16550
16551
5/6
✓ Branch 0 taken 1164704 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1161984 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1186880 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16552 {
16553
2/2
✓ Branch 0 taken 3902976 times.
✓ Branch 1 taken 22176 times.
3925152 for(int32_t k=0; k<176; k++)
16554 {
16555
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3902976 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3902976 if((Header->zelda_version == 0x192)&&(Header->build>149))
16556 {
16557 if((Header->zelda_version == 0x192)&&(Header->build!=153))
16558 {
16559 temp_mapscr->cset[k]=((temp_mapscr->data[k]>>8)&7);
16560 }
16561 }
16562 else
16563 {
16564
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3902976 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3902976 if((Header->zelda_version < 0x192)||
16565 ((Header->zelda_version == 0x192)&&(Header->build<21)))
16566 {
16567 3902976 temp_mapscr->sflag[k]=(temp_mapscr->data[k]>>11);
16568 3902976 }
16569
16570 3902976 temp_mapscr->cset[k]=((temp_mapscr->data[k]>>8)&7);
16571 }
16572
16573 3902976 temp_mapscr->data[k]=(temp_mapscr->data[k]&0xFF)+(old_combo_page<<8);
16574 3902976 }
16575 22176 }
16576
16577 /*if(version>12)
16578 {
16579 if(!p_getc(&(temp_mapscr->scrWidth),f))
16580 {
16581 return qe_invalid;
16582 }
16583 if(!p_getc(&(temp_mapscr->scrHeight),f))
16584 {
16585 return qe_invalid;
16586 }
16587 }*/
16588
16589
2/2
✓ Branch 0 taken 658376 times.
✓ Branch 1 taken 528504 times.
1186880 if(version>4)
16590 {
16591
1/2
✓ Branch 0 taken 658376 times.
✗ Branch 1 not taken.
658376 if(!p_igetw(&(temp_mapscr->screen_midi),f))
16592 {
16593 return qe_invalid;
16594 }
16595 658376 }
16596 else
16597 {
16598 528504 temp_mapscr->screen_midi = -1;
16599 }
16600
16601
2/2
✓ Branch 0 taken 658376 times.
✓ Branch 1 taken 528504 times.
1186880 if(version>=17)
16602 {
16603
1/2
✓ Branch 0 taken 658376 times.
✗ Branch 1 not taken.
658376 if(!p_getc(&(temp_mapscr->lens_layer),f))
16604 {
16605 return qe_invalid;
16606 }
16607 658376 }
16608 else
16609 {
16610 528504 temp_mapscr->lens_layer = llNORMAL;
16611 }
16612
16613
2/2
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 658376 times.
1186880 if(version>6)
16614 {
16615 dword bits;
16616
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 658376 times.
658376 if(!p_igetl(&bits,f))
16617 {
16618 return qe_invalid;
16619 }
16620
16621 int32_t m;
16622 float tempfloat;
16623 word tempw;
16624 658376 temp_mapscr->ffcCountMarkDirty();
16625 658376 temp_mapscr->ffcs.clear();
16626 658376 temp_mapscr->resizeFFC(std::bit_width(bits));
16627
2/2
✓ Branch 0 taken 658376 times.
✓ Branch 1 taken 21068032 times.
21726408 for(m=0; m<32; m++)
16628 {
16629
2/2
✓ Branch 0 taken 20792030 times.
✓ Branch 1 taken 276002 times.
21068032 if((bits>>m)&1)
16630 {
16631 276002 ffcdata& tempffc = temp_mapscr->ffcs[m];
16632
1/2
✓ Branch 0 taken 276002 times.
✗ Branch 1 not taken.
276002 if(!p_igetw(&tempw,f))
16633 {
16634 return qe_invalid;
16635 }
16636 276002 tempffc.data = tempw;
16637
16638
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 276002 times.
276002 if(!p_getc(&(tempffc.cset),f))
16639 {
16640 return qe_invalid;
16641 }
16642
16643
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 276002 times.
276002 if(!p_igetw(&(tempffc.delay),f))
16644 {
16645 return qe_invalid;
16646 }
16647
16648
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 276002 times.
276002 if(version < 9)
16649 {
16650 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16651 {
16652 return qe_invalid;
16653 }
16654
16655 tempffc.x=zslongToFix(int32_t(tempfloat*10000));
16656
16657 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16658 {
16659 return qe_invalid;
16660 }
16661
16662 tempffc.y=zslongToFix(int32_t(tempfloat*10000));
16663
16664 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16665 {
16666 return qe_invalid;
16667 }
16668
16669 tempffc.vx=zslongToFix(int32_t(tempfloat*10000));
16670
16671 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16672 {
16673 return qe_invalid;
16674 }
16675
16676 tempffc.vy=zslongToFix(int32_t(tempfloat*10000));
16677
16678 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16679 {
16680 return qe_invalid;
16681 }
16682
16683 tempffc.ax=zslongToFix(int32_t(tempfloat*10000));
16684
16685 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16686 {
16687 return qe_invalid;
16688 }
16689
16690 tempffc.ay=zslongToFix(int32_t(tempfloat*10000));
16691 }
16692 else
16693 {
16694
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 276002 times.
276002 if(!p_igetzf(&(tempffc.x),f))
16695 {
16696 return qe_invalid;
16697 }
16698
16699
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 276002 times.
276002 if(!p_igetzf(&(tempffc.y),f))
16700 {
16701 return qe_invalid;
16702 }
16703
16704
1/2
✓ Branch 0 taken 276002 times.
✗ Branch 1 not taken.
276002 if(!p_igetzf(&(tempffc.vx),f))
16705 {
16706 return qe_invalid;
16707 }
16708
16709
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 276002 times.
276002 if(!p_igetzf(&(tempffc.vy),f))
16710 {
16711 return qe_invalid;
16712 }
16713
16714
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 276002 times.
276002 if(!p_igetzf(&(tempffc.ax),f))
16715 {
16716 return qe_invalid;
16717 }
16718
16719
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 276002 times.
276002 if(!p_igetzf(&(tempffc.ay),f))
16720 {
16721 return qe_invalid;
16722 }
16723 }
16724
16725
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 276002 times.
276002 if(!p_getc(&(tempffc.link),f))
16726 {
16727 return qe_invalid;
16728 }
16729
16730
1/2
✓ Branch 0 taken 276002 times.
✗ Branch 1 not taken.
276002 if(version>7)
16731 {
16732
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 276002 times.
276002 if(!p_getc(&tempbyte,f))
16733 {
16734 return qe_invalid;
16735 }
16736
16737 276002 tempffc.hit_width = (tempbyte&0x3F)+1;
16738 276002 tempffc.txsz = (tempbyte>>6)+1;
16739
16740
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 276002 times.
276002 if(!p_getc(&tempbyte,f))
16741 {
16742 return qe_invalid;
16743 }
16744
16745 276002 tempffc.hit_height = (tempbyte&0x3F)+1;
16746 276002 tempffc.tysz = (tempbyte>>6)+1;
16747
16748
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 276002 times.
276002 if(!p_igetl(&(tempffc.flags),f))
16749 {
16750 return qe_invalid;
16751 }
16752 276002 }
16753 else
16754 {
16755 tempffc.hit_width=16;
16756 tempffc.hit_height=16;
16757 tempffc.txsz=1;
16758 tempffc.tysz=1;
16759 tempffc.flags=ffc_none;
16760 }
16761
16762 276002 tempffc.updateSolid();
16763
16764
16765
4/6
✓ Branch 0 taken 276002 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 269998 times.
✓ Branch 3 taken 6004 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 269998 times.
276002 if(Header->zelda_version == 0x211 || (Header->zelda_version == 0x250 && Header->build<20))
16766 {
16767 tempffc.flags|=ffc_ignoreholdup;
16768 }
16769
16770
1/2
✓ Branch 0 taken 276002 times.
✗ Branch 1 not taken.
276002 if(version>9)
16771 {
16772
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 276002 times.
276002 if(!p_igetw(&(tempffc.script),f))
16773 {
16774 return qe_invalid;
16775 }
16776 276002 }
16777 else
16778 {
16779 tempffc.script=0;
16780 }
16781
16782
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 276002 times.
276002 if(version>10)
16783 {
16784
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 276002 times.
276002 if(!p_igetl(&(tempffc.initd[0]),f))
16785 {
16786 return qe_invalid;
16787 }
16788
16789
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 276002 times.
276002 if(!p_igetl(&(tempffc.initd[1]),f))
16790 {
16791 return qe_invalid;
16792 }
16793
16794
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 276002 times.
276002 if(!p_igetl(&(tempffc.initd[2]),f))
16795 {
16796 return qe_invalid;
16797 }
16798
16799
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 276002 times.
276002 if(!p_igetl(&(tempffc.initd[3]),f))
16800 {
16801 return qe_invalid;
16802 }
16803
16804
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 276002 times.
276002 if(!p_igetl(&(tempffc.initd[4]),f))
16805 {
16806 return qe_invalid;
16807 }
16808
16809
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 276002 times.
276002 if(!p_igetl(&(tempffc.initd[5]),f))
16810 {
16811 return qe_invalid;
16812 }
16813
16814
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 276002 times.
276002 if(!p_igetl(&(tempffc.initd[6]),f))
16815 {
16816 return qe_invalid;
16817 }
16818
16819
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 276002 times.
276002 if(!p_igetl(&(tempffc.initd[7]),f))
16820 {
16821 return qe_invalid;
16822 }
16823
16824
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 276002 times.
276002 if(!p_getc(&(tempbyte),f))
16825 {
16826 return qe_invalid;
16827 }
16828
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 276002 times.
276002 if(!p_getc(&(tempbyte),f))
16829 {
16830 return qe_invalid;
16831 }
16832 276002 }
16833
16834
1/2
✓ Branch 0 taken 276002 times.
✗ Branch 1 not taken.
276002 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
16835 {
16836 tempffc.script = 0;
16837 for(int q = 0; q < 8; ++q)
16838 tempffc.initd[q] = 0;
16839 }
16840
1/2
✓ Branch 0 taken 276002 times.
✗ Branch 1 not taken.
276002 if(version <= 11)
16841 {
16842 fixffcs=true;
16843 }
16844 276002 }
16845 21068032 }
16846
16847 658376 temp_mapscr->shinkToFitFFCs();
16848 658376 }
16849
16850
16851 //add in the new whistle flags
16852
2/2
✓ Branch 0 taken 658376 times.
✓ Branch 1 taken 528504 times.
1186880 if(version<13)
16853 {
16854
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 528380 times.
528504 if(temp_mapscr->flags & fWHISTLE)
16855 {
16856 124 temp_mapscr->flags7 |= (fWHISTLEPAL | fWHISTLEWATER);
16857 124 }
16858 528504 }
16859
16860 //2.55 starts here
16861
3/4
✓ Branch 0 taken 34408 times.
✓ Branch 1 taken 1152472 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34408 times.
1186880 if ( version >= 19 && Header->zelda_version > 0x253 )
16862 {
16863 // mapscr fields that were never used, so are now removed:
16864 // int32_t npcstrings[10];
16865 // int16_t new_items[10];
16866 // int16_t new_item_x[10];
16867 // int16_t new_item_y[10];
16868
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34408 times.
34408 if (pack_fseek(f, 100))
16869 {
16870 return qe_invalid;
16871 }
16872 34408 }
16873
16874
3/4
✓ Branch 0 taken 34408 times.
✓ Branch 1 taken 1152472 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34408 times.
1186880 if ( version >= 20 && Header->zelda_version > 0x253 )
16875 {
16876
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34408 times.
34408 if(!p_igetw(&(temp_mapscr->script),f))
16877 {
16878 return qe_invalid;
16879 }
16880
2/2
✓ Branch 0 taken 275264 times.
✓ Branch 1 taken 34408 times.
309672 for ( int32_t q = 0; q < 8; q++)
16881 {
16882
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275264 times.
275264 if(!p_igetl(&(temp_mapscr->screeninitd[q]),f))
16883 {
16884 return qe_invalid;
16885 }
16886 275264 }
16887 34408 }
16888
2/2
✓ Branch 0 taken 1152472 times.
✓ Branch 1 taken 34408 times.
1186880 if ( version < 20 )
16889 {
16890 1152472 temp_mapscr->script = 0;
16891
2/2
✓ Branch 0 taken 9219776 times.
✓ Branch 1 taken 1152472 times.
10372248 for ( int32_t q = 0; q < 8; q++) temp_mapscr->screeninitd[q] = 0;
16892 1152472 }
16893
3/4
✓ Branch 0 taken 34408 times.
✓ Branch 1 taken 1152472 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34408 times.
1186880 if ( version >= 21 && Header->zelda_version > 0x253 )
16894 {
16895
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34408 times.
34408 if(!p_getc(&(temp_mapscr->preloadscript),f))
16896 {
16897 return qe_invalid;
16898 }
16899 34408 }
16900
2/2
✓ Branch 0 taken 34408 times.
✓ Branch 1 taken 1152472 times.
1186880 if ( version < 21 )
16901 {
16902 1152472 temp_mapscr->preloadscript = 0;
16903 1152472 }
16904
16905
3/4
✓ Branch 0 taken 34408 times.
✓ Branch 1 taken 1152472 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34408 times.
1186880 if ( version >= 22 && Header->zelda_version > 0x253 ) //26th June, 2019; Layer Visibility
16906 {
16907
1/2
✓ Branch 0 taken 34408 times.
✗ Branch 1 not taken.
34408 if(!p_getc(&(temp_mapscr->hidelayers ),f))
16908 {
16909 return qe_invalid;
16910 }
16911
1/2
✓ Branch 0 taken 34408 times.
✗ Branch 1 not taken.
34408 if(!p_getc(&(temp_mapscr->hidescriptlayers ),f))
16912 {
16913 return qe_invalid;
16914 }
16915 34408 }
16916
2/2
✓ Branch 0 taken 34408 times.
✓ Branch 1 taken 1152472 times.
1186880 if ( version < 22 )
16917 {
16918 1152472 temp_mapscr->hidelayers = 0;
16919 1152472 temp_mapscr->hidescriptlayers = 0;
16920 1152472 }
16921
16922 //Dodongos in 2.10 used the boss roar, not the dodongo sound. -Z
16923 //May be any version before 2.11. -Z
16924 /* --not the roar, the HIT SFX
16925 if ( Header->zelda_version <= 0x210 )
16926 {
16927 if ( temp_mapscr->bosssfx == WAV_DODONGO )
16928 {
16929 temp_mapscr->bosssfx = WAV_ROAR;
16930 }
16931 }
16932 */
16933
2/2
✓ Branch 0 taken 4747520 times.
✓ Branch 1 taken 1186880 times.
5934400 for(int32_t k=0; k<4; k++)
16934 {
16935
1/2
✓ Branch 0 taken 4747520 times.
✗ Branch 1 not taken.
4747520 if(temp_mapscr->door[k] == dNONE)
16936 temp_mapscr->door[k] = dWALL;
16937 4747520 }
16938
16939 1186880 return 0;
16940 1186880 }
16941 1390064 int32_t readmapscreen(PACKFILE *f, zquestheader *Header, mapscr *temp_mapscr, word version, int scrind)
16942 {
16943
2/2
✓ Branch 0 taken 1186880 times.
✓ Branch 1 taken 203184 times.
1390064 if(version < 23)
16944 {
16945 1186880 auto ret = readmapscreen_old(f,Header,temp_mapscr,version,scrind);
16946
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1186880 times.
1186880 if(ret) return ret;
16947 1186880 }
16948 else
16949 {
16950
1/2
✓ Branch 0 taken 203184 times.
✗ Branch 1 not taken.
203184 if(!p_getc(&(temp_mapscr->valid),f))
16951 return qe_invalid;
16952
2/2
✓ Branch 0 taken 106120 times.
✓ Branch 1 taken 97064 times.
203184 if(!(temp_mapscr->valid & mVALID))
16953 {
16954 97064 int map = scrind/MAPSCRS;
16955 97064 int screen = scrind%MAPSCRS;
16956
4/6
✓ Branch 0 taken 89962 times.
✓ Branch 1 taken 7102 times.
✓ Branch 2 taken 89962 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 89962 times.
97064 if(version > 25 && scrind > -1 && (map*6+5) < map_autolayers.size())
16957 {
16958 //Empty screen, apply autolayers
16959
2/2
✓ Branch 0 taken 539772 times.
✓ Branch 1 taken 89962 times.
629734 for(int q = 0; q < 6; ++q)
16960 {
16961 539772 auto layermap = map_autolayers[map*6+q];
16962 539772 temp_mapscr->layermap[q] = layermap;
16963
2/2
✓ Branch 0 taken 524232 times.
✓ Branch 1 taken 15540 times.
539772 if(layermap)
16964 15540 temp_mapscr->layerscreen[q] = screen;
16965 539772 }
16966 89962 }
16967 97064 return 0;
16968 }
16969 uint32_t scr_has_flags;
16970
1/2
✓ Branch 0 taken 106120 times.
✗ Branch 1 not taken.
106120 if(!p_igetl(&scr_has_flags,f))
16971 return qe_invalid;
16972
16973
2/2
✓ Branch 0 taken 10458 times.
✓ Branch 1 taken 95662 times.
106120 if(scr_has_flags & SCRHAS_ROOMDATA)
16974 {
16975
1/2
✓ Branch 0 taken 95662 times.
✗ Branch 1 not taken.
95662 if(!p_getc(&(temp_mapscr->guy),f))
16976 return qe_invalid;
16977
2/2
✓ Branch 0 taken 95542 times.
✓ Branch 1 taken 120 times.
95662 if(version > 26)
16978 {
16979
1/2
✓ Branch 0 taken 95542 times.
✗ Branch 1 not taken.
95542 if(!p_igetl(&(temp_mapscr->guytile),f))
16980 return qe_invalid;
16981
1/2
✓ Branch 0 taken 95542 times.
✗ Branch 1 not taken.
95542 if(!p_getc(&(temp_mapscr->guycs),f))
16982 return qe_invalid;
16983
1/2
✓ Branch 0 taken 95542 times.
✗ Branch 1 not taken.
95542 if(!p_igetw(&(temp_mapscr->roomflags),f))
16984 return qe_invalid;
16985 95542 }
16986 else
16987 {
16988 120 temp_mapscr->guytile = -1; //signal to use default guy values
16989
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 SETFLAG(temp_mapscr->roomflags,RFL_ALWAYS_GUY,temp_mapscr->guy==gFAIRY);
16990
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
120 SETFLAG(temp_mapscr->roomflags,RFL_GUYFIRES,temp_mapscr->guy!=gFAIRY || !get_qr(qr_NOFAIRYGUYFIRES));
16991 }
16992
1/2
✓ Branch 0 taken 95662 times.
✗ Branch 1 not taken.
95662 if(!p_igetw(&(temp_mapscr->str),f))
16993 return qe_invalid;
16994
1/2
✓ Branch 0 taken 95662 times.
✗ Branch 1 not taken.
95662 if(!p_getc(&(temp_mapscr->room),f))
16995 return qe_invalid;
16996
1/2
✓ Branch 0 taken 95662 times.
✗ Branch 1 not taken.
95662 if(!p_igetw(&(temp_mapscr->catchall),f))
16997 return qe_invalid;
16998 95662 }
16999
2/2
✓ Branch 0 taken 103757 times.
✓ Branch 1 taken 2363 times.
106120 if(scr_has_flags & SCRHAS_ITEM)
17000 {
17001
1/2
✓ Branch 0 taken 2363 times.
✗ Branch 1 not taken.
2363 if(!p_getc(&(temp_mapscr->item),f))
17002 return qe_invalid;
17003
1/2
✓ Branch 0 taken 2363 times.
✗ Branch 1 not taken.
2363 if(!p_getc(&(temp_mapscr->hasitem),f))
17004 return qe_invalid;
17005
1/2
✓ Branch 0 taken 2363 times.
✗ Branch 1 not taken.
2363 if(!p_getc(&(temp_mapscr->itemx),f))
17006 return qe_invalid;
17007
1/2
✓ Branch 0 taken 2363 times.
✗ Branch 1 not taken.
2363 if(!p_getc(&(temp_mapscr->itemy),f))
17008 return qe_invalid;
17009 2363 }
17010
2/2
✓ Branch 0 taken 95455 times.
✓ Branch 1 taken 10665 times.
106120 if(scr_has_flags & (SCRHAS_SWARP|SCRHAS_TWARP))
17011 {
17012
1/2
✓ Branch 0 taken 10665 times.
✗ Branch 1 not taken.
10665 if(!p_igetw(&temp_mapscr->warpreturnc,f))
17013 return qe_invalid;
17014 10665 }
17015
2/2
✓ Branch 0 taken 103638 times.
✓ Branch 1 taken 2482 times.
106120 if(scr_has_flags & SCRHAS_TWARP)
17016 {
17017
2/2
✓ Branch 0 taken 9928 times.
✓ Branch 1 taken 2482 times.
12410 for(int32_t i=0; i<4; i++)
17018 {
17019
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9928 times.
9928 if(!p_getc(&(temp_mapscr->tilewarptype[i]),f))
17020 return qe_invalid;
17021 9928 }
17022
2/2
✓ Branch 0 taken 9928 times.
✓ Branch 1 taken 2482 times.
12410 for(int32_t i=0; i<4; i++)
17023 {
17024
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9928 times.
9928 if(!p_igetw(&(temp_mapscr->tilewarpdmap[i]),f))
17025 return qe_invalid;
17026 9928 }
17027
2/2
✓ Branch 0 taken 9928 times.
✓ Branch 1 taken 2482 times.
12410 for(int32_t i=0; i<4; i++)
17028 {
17029
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9928 times.
9928 if(!p_getc(&(temp_mapscr->tilewarpscr[i]),f))
17030 return qe_invalid;
17031 9928 }
17032
1/2
✓ Branch 0 taken 2482 times.
✗ Branch 1 not taken.
2482 if(!p_getc(&(temp_mapscr->tilewarpoverlayflags),f))
17033 return qe_invalid;
17034 2482 }
17035
2/2
✓ Branch 0 taken 97462 times.
✓ Branch 1 taken 8658 times.
106120 if(scr_has_flags & SCRHAS_SWARP)
17036 {
17037
2/2
✓ Branch 0 taken 34632 times.
✓ Branch 1 taken 8658 times.
43290 for(int32_t i=0; i<4; i++)
17038 {
17039
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34632 times.
34632 if(!p_getc(&(temp_mapscr->sidewarptype[i]),f))
17040 return qe_invalid;
17041 34632 }
17042
2/2
✓ Branch 0 taken 34632 times.
✓ Branch 1 taken 8658 times.
43290 for(int32_t i=0; i<4; i++)
17043 {
17044
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34632 times.
34632 if(!p_igetw(&(temp_mapscr->sidewarpdmap[i]),f))
17045 return qe_invalid;
17046 34632 }
17047
2/2
✓ Branch 0 taken 34632 times.
✓ Branch 1 taken 8658 times.
43290 for(int32_t i=0; i<4; i++)
17048 {
17049
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34632 times.
34632 if(!p_getc(&(temp_mapscr->sidewarpscr[i]),f))
17050 return qe_invalid;
17051 34632 }
17052
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8658 times.
8658 if(!p_getc(&(temp_mapscr->sidewarpoverlayflags),f))
17053 return qe_invalid;
17054
1/2
✓ Branch 0 taken 8658 times.
✗ Branch 1 not taken.
8658 if(!p_getc(&(temp_mapscr->sidewarpindex),f))
17055 return qe_invalid;
17056 8658 }
17057
2/2
✓ Branch 0 taken 99488 times.
✓ Branch 1 taken 6632 times.
106120 if(scr_has_flags & SCRHAS_WARPRET)
17058 {
17059
2/2
✓ Branch 0 taken 26528 times.
✓ Branch 1 taken 6632 times.
33160 for(int32_t i=0; i<4; i++)
17060 {
17061
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26528 times.
26528 if(!p_getc(&(temp_mapscr->warpreturnx[i]),f))
17062 return qe_invalid;
17063 26528 }
17064
2/2
✓ Branch 0 taken 26528 times.
✓ Branch 1 taken 6632 times.
33160 for(int32_t i=0; i<4; i++)
17065 {
17066
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26528 times.
26528 if(!p_getc(&(temp_mapscr->warpreturny[i]),f))
17067 return qe_invalid;
17068 26528 }
17069
1/2
✓ Branch 0 taken 6632 times.
✗ Branch 1 not taken.
6632 if(!p_getc(&(temp_mapscr->warparrivalx),f))
17070 return qe_invalid;
17071
1/2
✓ Branch 0 taken 6632 times.
✗ Branch 1 not taken.
6632 if(!p_getc(&(temp_mapscr->warparrivaly),f))
17072 return qe_invalid;
17073 6632 }
17074
2/2
✓ Branch 0 taken 92607 times.
✓ Branch 1 taken 13513 times.
106120 if(scr_has_flags & SCRHAS_LAYERS)
17075 {
17076
2/2
✓ Branch 0 taken 81078 times.
✓ Branch 1 taken 13513 times.
94591 for(int32_t k=0; k<6; k++)
17077 {
17078
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 81078 times.
81078 if(!p_getc(&(temp_mapscr->layermap[k]),f))
17079 return qe_invalid;
17080 81078 }
17081
2/2
✓ Branch 0 taken 81078 times.
✓ Branch 1 taken 13513 times.
94591 for(int32_t k=0; k<6; k++)
17082 {
17083
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 81078 times.
81078 if(!p_getc(&(temp_mapscr->layerscreen[k]),f))
17084 return qe_invalid;
17085 81078 }
17086
2/2
✓ Branch 0 taken 81078 times.
✓ Branch 1 taken 13513 times.
94591 for(int32_t k=0; k<6; k++)
17087 {
17088
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 81078 times.
81078 if(!p_getc(&(temp_mapscr->layeropacity[k]),f))
17089 return qe_invalid;
17090 81078 }
17091
1/2
✓ Branch 0 taken 13513 times.
✗ Branch 1 not taken.
13513 if(!p_getc(&(temp_mapscr->hidelayers),f))
17092 return qe_invalid;
17093
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13513 times.
13513 if(!p_getc(&(temp_mapscr->hidescriptlayers),f))
17094 return qe_invalid;
17095 13513 }
17096
2/2
✓ Branch 0 taken 106016 times.
✓ Branch 1 taken 104 times.
106120 if(scr_has_flags & SCRHAS_MAZE)
17097 {
17098
2/2
✓ Branch 0 taken 416 times.
✓ Branch 1 taken 104 times.
520 for(int32_t k=0; k<4; k++)
17099 {
17100
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 416 times.
416 if(!p_getc(&(temp_mapscr->path[k]),f))
17101 return qe_invalid;
17102 416 }
17103
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 if(!p_getc(&(temp_mapscr->exitdir),f))
17104 return qe_invalid;
17105
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 if (version >= 32)
17106 {
17107
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 if (!p_getc(&temp_mapscr->maze_transition_wipe, f))
17108 return qe_invalid;
17109 104 }
17110 104 }
17111
2/2
✓ Branch 0 taken 77326 times.
✓ Branch 1 taken 28794 times.
106120 if(scr_has_flags & SCRHAS_D_S_U)
17112 {
17113
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77326 times.
77326 if(!p_igetw(&(temp_mapscr->door_combo_set),f))
17114 return qe_invalid;
17115
2/2
✓ Branch 0 taken 309304 times.
✓ Branch 1 taken 77326 times.
386630 for(int32_t k=0; k<4; k++)
17116 {
17117
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 309304 times.
309304 if(!p_getc(&(temp_mapscr->door[k]),f))
17118 return qe_invalid;
17119
3/4
✓ Branch 0 taken 360 times.
✓ Branch 1 taken 308944 times.
✓ Branch 2 taken 360 times.
✗ Branch 3 not taken.
309304 if(version < 29 && temp_mapscr->door[k] == dNONE)
17120 temp_mapscr->door[k] = dWALL;
17121 309304 }
17122
17123
1/2
✓ Branch 0 taken 77326 times.
✗ Branch 1 not taken.
77326 if(!p_getc(&(temp_mapscr->stairx),f))
17124 return qe_invalid;
17125
17126
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77326 times.
77326 if(!p_getc(&(temp_mapscr->stairy),f))
17127 return qe_invalid;
17128
1/2
✓ Branch 0 taken 77326 times.
✗ Branch 1 not taken.
77326 if(!p_igetw(&(temp_mapscr->undercombo),f))
17129 return qe_invalid;
17130
1/2
✓ Branch 0 taken 77326 times.
✗ Branch 1 not taken.
77326 if(!p_getc(&(temp_mapscr->undercset),f))
17131 return qe_invalid;
17132 77326 }
17133
2/2
✓ Branch 0 taken 10488 times.
✓ Branch 1 taken 18306 times.
28794 else if(version < 29)
17134 {
17135
2/2
✓ Branch 0 taken 41952 times.
✓ Branch 1 taken 10488 times.
52440 for(int k = 0; k < 4; ++k)
17136 41952 temp_mapscr->door[k] = dWALL;
17137 10488 }
17138
2/2
✓ Branch 0 taken 99643 times.
✓ Branch 1 taken 6477 times.
106120 if(scr_has_flags & SCRHAS_FLAGS)
17139 {
17140
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6477 times.
6477 if(!p_getc(&(temp_mapscr->flags),f))
17141 return qe_invalid;
17142
1/2
✓ Branch 0 taken 6477 times.
✗ Branch 1 not taken.
6477 if(!p_getc(&(temp_mapscr->flags2),f))
17143 return qe_invalid;
17144
1/2
✓ Branch 0 taken 6477 times.
✗ Branch 1 not taken.
6477 if(!p_getc(&(temp_mapscr->flags3),f))
17145 return qe_invalid;
17146
1/2
✓ Branch 0 taken 6477 times.
✗ Branch 1 not taken.
6477 if(!p_getc(&(temp_mapscr->flags4),f))
17147 return qe_invalid;
17148
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6477 times.
6477 if(!p_getc(&(temp_mapscr->flags5),f))
17149 return qe_invalid;
17150
1/2
✓ Branch 0 taken 6477 times.
✗ Branch 1 not taken.
6477 if(!p_getc(&(temp_mapscr->flags6),f))
17151 return qe_invalid;
17152
1/2
✓ Branch 0 taken 6477 times.
✗ Branch 1 not taken.
6477 if(!p_getc(&(temp_mapscr->flags7),f))
17153 return qe_invalid;
17154
1/2
✓ Branch 0 taken 6477 times.
✗ Branch 1 not taken.
6477 if(!p_getc(&(temp_mapscr->flags8),f))
17155 return qe_invalid;
17156
1/2
✓ Branch 0 taken 6477 times.
✗ Branch 1 not taken.
6477 if(!p_getc(&(temp_mapscr->flags9),f))
17157 return qe_invalid;
17158
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6477 times.
6477 if(!p_getc(&(temp_mapscr->flags10),f))
17159 return qe_invalid;
17160
1/2
✓ Branch 0 taken 6477 times.
✗ Branch 1 not taken.
6477 if(!p_getc(&(temp_mapscr->flags11),f))
17161 return qe_invalid;
17162 6477 }
17163
2/2
✓ Branch 0 taken 100837 times.
✓ Branch 1 taken 5283 times.
106120 if(scr_has_flags & SCRHAS_ENEMY)
17164 {
17165
2/2
✓ Branch 0 taken 52830 times.
✓ Branch 1 taken 5283 times.
58113 for(int32_t k=0; k<10; k++)
17166 {
17167
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52830 times.
52830 if(!p_igetw(&(temp_mapscr->enemy[k]),f))
17168 return qe_invalid;
17169
1/2
✓ Branch 0 taken 52830 times.
✗ Branch 1 not taken.
52830 if (unsigned(temp_mapscr->enemy[k]) > MAXGUYS)
17170 temp_mapscr->enemy[k] = 0;
17171 52830 }
17172
1/2
✓ Branch 0 taken 5283 times.
✗ Branch 1 not taken.
5283 if(!p_getc(&(temp_mapscr->pattern),f))
17173 return qe_invalid;
17174 5283 }
17175
2/2
✓ Branch 0 taken 105715 times.
✓ Branch 1 taken 405 times.
106120 if(scr_has_flags & SCRHAS_CARRY)
17176 {
17177
1/2
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
405 if(!p_igetw(&(temp_mapscr->noreset),f))
17178 return qe_invalid;
17179
1/2
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
405 if(!p_igetw(&(temp_mapscr->nocarry),f))
17180 return qe_invalid;
17181
1/2
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
405 if(!p_getc(&(temp_mapscr->nextmap),f))
17182 return qe_invalid;
17183
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 405 times.
405 if(!p_getc(&(temp_mapscr->nextscr),f))
17184 return qe_invalid;
17185 405 }
17186
2/2
✓ Branch 0 taken 105531 times.
✓ Branch 1 taken 589 times.
106120 if(scr_has_flags & SCRHAS_SCRIPT)
17187 {
17188
1/2
✓ Branch 0 taken 589 times.
✗ Branch 1 not taken.
589 if(!p_igetw(&(temp_mapscr->script),f))
17189 return qe_invalid;
17190
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 589 times.
589 if(!p_getc(&(temp_mapscr->preloadscript),f))
17191 return qe_invalid;
17192
2/2
✓ Branch 0 taken 4712 times.
✓ Branch 1 taken 589 times.
5301 for ( int32_t q = 0; q < 8; q++ )
17193 {
17194
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4712 times.
4712 if(!p_igetl(&(temp_mapscr->screeninitd[q]),f))
17195 return qe_invalid;
17196 4712 }
17197 589 }
17198
2/2
✓ Branch 0 taken 74653 times.
✓ Branch 1 taken 31467 times.
106120 if(scr_has_flags & SCRHAS_SECRETS)
17199 {
17200
2/2
✓ Branch 0 taken 4027776 times.
✓ Branch 1 taken 31467 times.
4059243 for(int32_t k=0; k<128; k++)
17201 {
17202
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4027776 times.
4027776 if(!p_igetw(&(temp_mapscr->secretcombo[k]),f))
17203 return qe_invalid;
17204 4027776 }
17205
2/2
✓ Branch 0 taken 4027776 times.
✓ Branch 1 taken 31467 times.
4059243 for(int32_t k=0; k<128; k++)
17206 {
17207
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4027776 times.
4027776 if(!p_getc(&(temp_mapscr->secretcset[k]),f))
17208 return qe_invalid;
17209 4027776 }
17210
2/2
✓ Branch 0 taken 4027776 times.
✓ Branch 1 taken 31467 times.
4059243 for(int32_t k=0; k<128; k++)
17211 {
17212
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4027776 times.
4027776 if(!p_getc(&(temp_mapscr->secretflag[k]),f))
17213 return qe_invalid;
17214 4027776 }
17215 31467 }
17216
2/2
✓ Branch 0 taken 40661 times.
✓ Branch 1 taken 65459 times.
106120 if(scr_has_flags & SCRHAS_COMBOFLAG)
17217 {
17218
2/2
✓ Branch 0 taken 11520784 times.
✓ Branch 1 taken 65459 times.
11586243 for(int32_t k=0; k<176; ++k)
17219 {
17220
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11520784 times.
11520784 if(!p_igetw(&(temp_mapscr->data[k]),f))
17221 return qe_invalid;
17222 11520784 }
17223
2/2
✓ Branch 0 taken 11520784 times.
✓ Branch 1 taken 65459 times.
11586243 for(int32_t k=0; k<176; ++k)
17224 {
17225
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11520784 times.
11520784 if(!p_getc(&(temp_mapscr->sflag[k]),f))
17226 return qe_invalid;
17227 11520784 }
17228
2/2
✓ Branch 0 taken 11520784 times.
✓ Branch 1 taken 65459 times.
11586243 for(int32_t k=0; k<176; ++k)
17229 {
17230
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11520784 times.
11520784 if(!p_getc(&(temp_mapscr->cset[k]),f))
17231 return qe_invalid;
17232 11520784 }
17233 65459 }
17234
1/2
✓ Branch 0 taken 106120 times.
✗ Branch 1 not taken.
106120 if(scr_has_flags & SCRHAS_MISC)
17235 {
17236
1/2
✓ Branch 0 taken 106120 times.
✗ Branch 1 not taken.
106120 if(!p_igetw(&(temp_mapscr->color),f))
17237 return qe_invalid;
17238
1/2
✓ Branch 0 taken 106120 times.
✗ Branch 1 not taken.
106120 if(!p_getc(&(temp_mapscr->csensitive),f))
17239 return qe_invalid;
17240
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106120 times.
106120 if(!p_getc(&(temp_mapscr->oceansfx),f))
17241 return qe_invalid;
17242
1/2
✓ Branch 0 taken 106120 times.
✗ Branch 1 not taken.
106120 if(!p_getc(&(temp_mapscr->bosssfx),f))
17243 return qe_invalid;
17244
1/2
✓ Branch 0 taken 106120 times.
✗ Branch 1 not taken.
106120 if(!p_getc(&(temp_mapscr->secretsfx),f))
17245 return qe_invalid;
17246
1/2
✓ Branch 0 taken 106120 times.
✗ Branch 1 not taken.
106120 if(!p_getc(&(temp_mapscr->holdupsfx),f))
17247 return qe_invalid;
17248
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106120 times.
106120 if(!p_igetw(&(temp_mapscr->timedwarptics),f))
17249 return qe_invalid;
17250
1/2
✓ Branch 0 taken 106120 times.
✗ Branch 1 not taken.
106120 if(!p_igetw(&(temp_mapscr->screen_midi),f))
17251 return qe_invalid;
17252
1/2
✓ Branch 0 taken 106120 times.
✗ Branch 1 not taken.
106120 if(!p_getc(&(temp_mapscr->lens_layer),f))
17253 return qe_invalid;
17254
2/2
✓ Branch 0 taken 10578 times.
✓ Branch 1 taken 95542 times.
106120 if(version > 27)
17255 {
17256
1/2
✓ Branch 0 taken 95542 times.
✗ Branch 1 not taken.
95542 if(!p_getc(&(temp_mapscr->lens_show),f))
17257 return qe_invalid;
17258
1/2
✓ Branch 0 taken 95542 times.
✗ Branch 1 not taken.
95542 if(!p_getc(&(temp_mapscr->lens_hide),f))
17259 return qe_invalid;
17260 95542 }
17261 106120 }
17262 else
17263 {
17264 temp_mapscr->screen_midi = -1;
17265 temp_mapscr->csensitive = 1;
17266 }
17267 //FFC
17268 106120 bool old_ff = version < 25;
17269 106120 dword bits = 0;
17270 106120 word numffc = 32;
17271
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106120 times.
106120 if(old_ff)
17272 {
17273 if(!p_igetl(&bits,f))
17274 return qe_invalid;
17275 }
17276 else
17277 {
17278
2/4
✓ Branch 0 taken 106120 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 106120 times.
106120 if(!p_igetw(&numffc,f) || numffc > MAXFFCS)
17279 return qe_invalid;
17280 }
17281
17282 106120 temp_mapscr->ffcCountMarkDirty();
17283 106120 temp_mapscr->ffcs.clear();
17284 106120 temp_mapscr->resizeFFC(numffc);
17285
17286 byte tempbyte;
17287 word tempw;
17288
4/6
✓ Branch 0 taken 158 times.
✓ Branch 1 taken 105962 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 158 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 158 times.
106120 static ffcdata nil_ffc;
17289
2/2
✓ Branch 0 taken 1981860 times.
✓ Branch 1 taken 106120 times.
2087980 for(word m = 0; m < numffc; ++m)
17290 {
17291
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1981860 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1981860 if(old_ff && !(bits & (1<<m))) continue;
17292
17293
1/2
✓ Branch 0 taken 1981860 times.
✗ Branch 1 not taken.
1981860 ffcdata& tempffc = (m < MAXFFCS)
17294 1981860 ? temp_mapscr->ffcs[m]
17295 : nil_ffc; //sanity
17296
17297
1/2
✓ Branch 0 taken 1981860 times.
✗ Branch 1 not taken.
1981860 if(!p_igetw(&tempw,f))
17298 return qe_invalid;
17299
3/4
✓ Branch 0 taken 1981860 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14441 times.
✓ Branch 3 taken 1967419 times.
1981860 if(!old_ff && !tempw) //empty ffc, nothing more to load
17300 1967419 continue;
17301 14441 tempffc.data = tempw;
17302
17303
1/2
✓ Branch 0 taken 14441 times.
✗ Branch 1 not taken.
14441 if(!p_getc(&(tempffc.cset),f))
17304 return qe_invalid;
17305
1/2
✓ Branch 0 taken 14441 times.
✗ Branch 1 not taken.
14441 if(!p_igetw(&(tempffc.delay),f))
17306 return qe_invalid;
17307
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14441 times.
14441 if(!p_igetzf(&(tempffc.x),f))
17308 return qe_invalid;
17309
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14441 times.
14441 if(!p_igetzf(&(tempffc.y),f))
17310 return qe_invalid;
17311
1/2
✓ Branch 0 taken 14441 times.
✗ Branch 1 not taken.
14441 if(!p_igetzf(&(tempffc.vx),f))
17312 return qe_invalid;
17313
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14441 times.
14441 if(!p_igetzf(&(tempffc.vy),f))
17314 return qe_invalid;
17315
1/2
✓ Branch 0 taken 14441 times.
✗ Branch 1 not taken.
14441 if(!p_igetzf(&(tempffc.ax),f))
17316 return qe_invalid;
17317
1/2
✓ Branch 0 taken 14441 times.
✗ Branch 1 not taken.
14441 if(!p_igetzf(&(tempffc.ay),f))
17318 return qe_invalid;
17319
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14441 times.
14441 if(!p_getc(&(tempffc.link),f))
17320 return qe_invalid;
17321
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14441 times.
14441 if(version < 24)
17322 {
17323 if(!p_getc(&tempbyte,f))
17324 return qe_invalid;
17325 tempffc.hit_width = (tempbyte&0x3F)+1;
17326 tempffc.txsz = (tempbyte>>6)+1;
17327 if(!p_getc(&tempbyte,f))
17328 return qe_invalid;
17329 tempffc.hit_height = (tempbyte&0x3F)+1;
17330 tempffc.tysz = (tempbyte>>6)+1;
17331 }
17332 else
17333 {
17334
1/2
✓ Branch 0 taken 14441 times.
✗ Branch 1 not taken.
14441 if(!p_igetl(&(tempffc.hit_width),f))
17335 return qe_invalid;
17336
1/2
✓ Branch 0 taken 14441 times.
✗ Branch 1 not taken.
14441 if(!p_igetl(&(tempffc.hit_height),f))
17337 return qe_invalid;
17338
1/2
✓ Branch 0 taken 14441 times.
✗ Branch 1 not taken.
14441 if(!p_getc(&(tempffc.txsz),f))
17339 return qe_invalid;
17340
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14441 times.
14441 if(!p_getc(&(tempffc.tysz),f))
17341 return qe_invalid;
17342 }
17343
1/2
✓ Branch 0 taken 14441 times.
✗ Branch 1 not taken.
14441 if(!p_igetl(&(tempffc.flags),f))
17344 return qe_invalid;
17345 14441 tempffc.updateSolid();
17346
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14441 times.
14441 if(!p_igetw(&(tempffc.script),f))
17347 return qe_invalid;
17348
2/2
✓ Branch 0 taken 115528 times.
✓ Branch 1 taken 14441 times.
129969 for(auto q = 0; q < 8; ++q)
17349 {
17350
1/2
✓ Branch 0 taken 115528 times.
✗ Branch 1 not taken.
115528 if(!p_igetl(&(tempffc.initd[q]),f))
17351 return qe_invalid;
17352 115528 }
17353
2/2
✓ Branch 0 taken 8011 times.
✓ Branch 1 taken 6430 times.
14441 if(version < 33)
17354 {
17355
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8011 times.
8011 if(!p_getc(&(tempbyte),f))
17356 return qe_invalid;
17357
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8011 times.
8011 if(!p_getc(&(tempbyte),f))
17358 return qe_invalid;
17359 8011 }
17360
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6430 times.
6430 else if(!p_getc(&(tempffc.layer),f))
17361 return qe_invalid;
17362
17363
1/2
✓ Branch 0 taken 14441 times.
✗ Branch 1 not taken.
14441 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
17364 {
17365 tempffc.script = 0;
17366 for(int q = 0; q < 8; ++q)
17367 tempffc.initd[q] = 0;
17368 }
17369 14441 }
17370 //END FFC
17371
2/2
✓ Branch 0 taken 38497 times.
✓ Branch 1 taken 67623 times.
106120 if(version > 29)
17372
1/2
✓ Branch 0 taken 67623 times.
✗ Branch 1 not taken.
67623 if(!p_getlstr(&temp_mapscr->usr_notes, f))
17373 return qe_invalid;
17374 }
17375
17376 1293000 temp_mapscr->shinkToFitFFCs();
17377
17378 1293000 return 0;
17379 1390064 }
17380
17381 481 int32_t readmaps(PACKFILE *f, zquestheader *Header)
17382 {
17383
2/2
✓ Branch 0 taken 457 times.
✓ Branch 1 taken 24 times.
481 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_maps);
17384 481 int32_t screen=0;
17385
17386 481 word version=0;
17387 dword dummy;
17388 int32_t screens_to_read;
17389
17390 481 mapscr temp_mapscr{};
17391 word temp_map_count;
17392 dword section_size;
17393
17394
5/6
✓ Branch 0 taken 463 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 457 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
481 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
17395 {
17396 18 screens_to_read=MAPSCRS192b136;
17397 18 }
17398 else
17399 {
17400 463 screens_to_read=MAPSCRS;
17401 }
17402
17403
2/2
✓ Branch 0 taken 457 times.
✓ Branch 1 taken 24 times.
481 if(Header->zelda_version > 0x192)
17404 {
17405 //section version info
17406
2/4
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 457 times.
✗ Branch 3 not taken.
457 if(!p_igetw(&version,f))
17407 {
17408 return qe_invalid;
17409 }
17410
17411 457 FFCore.quest_format[vMaps] = version;
17412
17413
2/4
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 457 times.
✗ Branch 3 not taken.
457 if(!p_igetw(&dummy,f))
17414 {
17415 return qe_invalid;
17416 }
17417
17418 //section size
17419
2/4
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 457 times.
✗ Branch 3 not taken.
457 if(!p_igetl(&section_size,f))
17420 {
17421 return qe_invalid;
17422 }
17423
17424 //finally... section data
17425
2/4
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 457 times.
✗ Branch 3 not taken.
457 if(!p_igetw(&temp_map_count,f))
17426 {
17427 return 5;
17428 }
17429 457 }
17430 else
17431 {
17432 24 temp_map_count=map_count;
17433 }
17434
17435
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 481 times.
481 if (temp_map_count > MAXMAPS)
17436 {
17437 return qe_invalid;
17438 }
17439
17440
2/2
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 1 times.
481 if (!should_skip)
17441 {
17442 480 const int32_t _mapsSize = MAPSCRS*temp_map_count;
17443 480 TheMaps.clear();
17444
1/2
✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
480 TheMaps.resize(_mapsSize);
17445 480 old_combo_pages.clear();
17446
1/2
✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
480 old_combo_pages.resize(_mapsSize);
17447 480 map_autolayers.clear();
17448
1/2
✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
480 map_autolayers.resize(temp_map_count*6);
17449
2/2
✓ Branch 0 taken 333 times.
✓ Branch 1 taken 147 times.
480 if(version >= 31)
17450 147 Regions = {};
17451 480 }
17452
17453
4/4
✓ Branch 0 taken 481 times.
✓ Branch 1 taken 10359 times.
✓ Branch 2 taken 10359 times.
✓ Branch 3 taken 481 times.
10840 for(int32_t i=0; i<temp_map_count && i<MAXMAPS; i++)
17454 {
17455 10359 byte valid=1;
17456
2/2
✓ Branch 0 taken 1627 times.
✓ Branch 1 taken 8732 times.
10359 if(version > 22)
17457 {
17458
2/4
✓ Branch 0 taken 1627 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1627 times.
✗ Branch 3 not taken.
1627 if(!p_getc(&valid,f))
17459 return qe_invalid;
17460 1627 }
17461
2/2
✓ Branch 0 taken 133 times.
✓ Branch 1 taken 10226 times.
10359 if(valid)
17462 {
17463
2/2
✓ Branch 0 taken 8862 times.
✓ Branch 1 taken 1364 times.
10226 if (version > 25)
17464 {
17465
2/2
✓ Branch 0 taken 8184 times.
✓ Branch 1 taken 1364 times.
9548 for(int q = 0; q < 6; ++q)
17466 {
17467
2/4
✓ Branch 0 taken 8184 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8184 times.
✗ Branch 3 not taken.
8184 if(!p_igetw(&map_autolayers[i*6+q],f))
17468 return qe_invalid;
17469 8184 }
17470 1364 }
17471
17472
2/2
✓ Branch 0 taken 9304 times.
✓ Branch 1 taken 922 times.
10226 if (version >= 31)
17473 {
17474 static regions_data tmp_rd;
17475
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 922 times.
922 regions_data& rd = should_skip ? tmp_rd : Regions[i];
17476
2/2
✓ Branch 0 taken 7376 times.
✓ Branch 1 taken 922 times.
8298 for(int32_t j=0; j<8; j++)
17477 {
17478
2/2
✓ Branch 0 taken 59008 times.
✓ Branch 1 taken 7376 times.
66384 for(int32_t k=0; k<8; k++)
17479 {
17480
2/4
✓ Branch 0 taken 59008 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 59008 times.
✗ Branch 3 not taken.
59008 if(!p_getc(&rd.region_ids[j][k],f))
17481 {
17482 return qe_invalid;
17483 }
17484 59008 }
17485 7376 }
17486 922 }
17487 10226 }
17488
2/2
✓ Branch 0 taken 1408152 times.
✓ Branch 1 taken 10359 times.
1418511 for(int32_t j=0; j<screens_to_read; j++)
17489 {
17490 1408152 screen=i*MAPSCRS+j;
17491
2/2
✓ Branch 0 taken 272 times.
✓ Branch 1 taken 1407880 times.
1408152 mapscr* scr = should_skip ? &temp_mapscr : &TheMaps[screen];
17492 1408152 scr->map = i;
17493 1408152 scr->screen = j;
17494
2/2
✓ Branch 0 taken 1390064 times.
✓ Branch 1 taken 18088 times.
1408152 if(valid)
17495
1/2
✓ Branch 0 taken 1390064 times.
✗ Branch 1 not taken.
1390064 readmapscreen(f, Header, scr, version, screen);
17496
1/2
✓ Branch 0 taken 18088 times.
✗ Branch 1 not taken.
18088 else if (!should_skip)
17497
1/2
✓ Branch 0 taken 18088 times.
✗ Branch 1 not taken.
18088 clear_screen(scr);
17498 1408152 }
17499
17500
2/2
✓ Branch 0 taken 10357 times.
✓ Branch 1 taken 2 times.
10359 if (should_skip)
17501 2 continue;
17502
17503
5/6
✓ Branch 0 taken 10189 times.
✓ Branch 1 taken 168 times.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 10171 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 18 times.
10357 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
17504 {
17505 168 int32_t index = (i*MAPSCRS+132);
17506
17507
1/2
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
168 TheMaps[index]=TheMaps[index-1];
17508
17509 168 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].data, TheMaps[i*MAPSCRS+131].data);
17510 168 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].sflag, TheMaps[i*MAPSCRS+131].sflag);
17511 168 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].cset, TheMaps[i*MAPSCRS+131].cset);
17512
17513
2/2
✓ Branch 0 taken 504 times.
✓ Branch 1 taken 168 times.
672 for(int32_t j=133; j<MAPSCRS; j++)
17514 {
17515 504 screen=i*MAPSCRS+j;
17516
17517
1/2
✓ Branch 0 taken 504 times.
✗ Branch 1 not taken.
504 TheMaps[screen].zero_memory();
17518 504 TheMaps[screen].valid = mVERSION;
17519 504 TheMaps[screen].screen_midi = -1;
17520 504 TheMaps[screen].csensitive = 1;
17521 504 }
17522 168 }
17523
17524
5/6
✓ Branch 0 taken 10189 times.
✓ Branch 1 taken 168 times.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 10171 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 18 times.
10357 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
17525 {
17526
2/2
✓ Branch 0 taken 22848 times.
✓ Branch 1 taken 168 times.
23016 for(int32_t j=0; j<MAPSCRS; j++)
17527 {
17528 22848 screen=i*MAPSCRS+j;
17529
1/2
✓ Branch 0 taken 22848 times.
✗ Branch 1 not taken.
22848 TheMaps[screen].door_combo_set=MakeDoors(i, j);
17530
17531
2/2
✓ Branch 0 taken 2924544 times.
✓ Branch 1 taken 22848 times.
2947392 for(int32_t k=0; k<128; k++)
17532 {
17533
1/2
✓ Branch 0 taken 2924544 times.
✗ Branch 1 not taken.
2924544 TheMaps[screen].secretcset[k]=tcmbcset2(i, TheMaps[screen].secretcombo[k]);
17534
1/2
✓ Branch 0 taken 2924544 times.
✗ Branch 1 not taken.
2924544 TheMaps[screen].secretflag[k]=tcmbflag2(i, TheMaps[screen].secretcombo[k]);
17535
1/2
✓ Branch 0 taken 2924544 times.
✗ Branch 1 not taken.
2924544 TheMaps[screen].secretcombo[k]=tcmbdat2(i, j, TheMaps[screen].secretcombo[k]);
17536 2924544 }
17537 22848 }
17538 168 }
17539 10357 }
17540 481 map_count = temp_map_count;
17541 481 return 0;
17542 481 }
17543
17544
17545 9131619 void update_combo(newcombo& cmb, word section_version)
17546 {
17547
2/2
✓ Branch 0 taken 1329913 times.
✓ Branch 1 taken 7801706 times.
9131619 if(section_version < 40)
17548 {
17549
3/3
✓ Branch 0 taken 5168 times.
✓ Branch 1 taken 46110 times.
✓ Branch 2 taken 7750428 times.
7801706 switch(cmb.type)
17550 {
17551 case cWATER: case cSHALLOWWATER:
17552 46110 cmb.attribytes[6] = iwRipples;
17553 46110 break;
17554 case cTALLGRASS: case cTALLGRASSNEXT: case cTALLGRASSTOUCHY:
17555 5168 cmb.attribytes[6] = iwTallGrass;
17556 5168 break;
17557 }
17558 7801706 }
17559
2/2
✓ Branch 0 taken 982482 times.
✓ Branch 1 taken 8149137 times.
9131619 if(section_version < 49)
17560 {
17561
4/4
✓ Branch 0 taken 8113916 times.
✓ Branch 1 taken 35221 times.
✓ Branch 2 taken 15697 times.
✓ Branch 3 taken 8098219 times.
8149137 if(cmb.type == cWATER || cmb.type == cSHALLOWWATER)
17562 50918 cmb.sfx_landing = WAV_ZN1SPLASH;
17563 8149137 }
17564 9131619 }
17565 294 int32_t readcombos_old(word section_version, PACKFILE *f, zquestheader *, word version, word build, word start_combo, word max_combos)
17566 {
17567
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 270 times.
294 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_combos);
17568 byte tempbyte;
17569
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 293 times.
294 if (!should_skip)
17570 {
17571 293 reset_all_combo_animations();
17572 293 init_combo_classes();
17573 293 }
17574
17575 // combos
17576 294 word combos_used=0;
17577 int32_t dummy;
17578 byte padding;
17579 294 newcombo temp_combo;
17580
17581
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 293 times.
294 if (!should_skip)
17582
2/2
✓ Branch 0 taken 19127040 times.
✓ Branch 1 taken 293 times.
19127333 for(int32_t q = start_combo; q < start_combo+max_combos; ++q)
17583
1/2
✓ Branch 0 taken 19127040 times.
✗ Branch 1 not taken.
19127333 combobuf[q].clear();
17584
17585
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 294 times.
294 if(version < 0x174)
17586 {
17587 combos_used=1024;
17588 }
17589
2/2
✓ Branch 0 taken 276 times.
✓ Branch 1 taken 18 times.
294 else if(version < 0x191)
17590 {
17591 18 combos_used=2048;
17592 18 }
17593 else
17594 {
17595
2/4
✓ Branch 0 taken 276 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 276 times.
✗ Branch 3 not taken.
276 if(!p_igetw(&combos_used,f))
17596 {
17597 return qe_invalid;
17598 }
17599 }
17600
17601 //finally... section data
17602
2/2
✓ Branch 0 taken 7666690 times.
✓ Branch 1 taken 294 times.
7666984 for(int32_t i=0; i<combos_used; i++)
17603 {
17604
1/2
✓ Branch 0 taken 7666690 times.
✗ Branch 1 not taken.
7666690 temp_combo.clear();
17605
1/2
✓ Branch 0 taken 7666690 times.
✗ Branch 1 not taken.
7666690 combo_trigger& temp_trigger = temp_combo.triggers.emplace_back();
17606
17607
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7463722 times.
7666690 if ( section_version >= 11 )
17608 {
17609
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_igetl(&temp_combo.tile,f))
17610 {
17611 return qe_invalid;
17612 }
17613 202968 }
17614 else
17615 {
17616
2/4
✓ Branch 0 taken 7463722 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7463722 times.
✗ Branch 3 not taken.
7463722 if(!p_igetw(&temp_combo.tile,f))
17617 {
17618 return qe_invalid;
17619 }
17620 }
17621 7666690 temp_combo.o_tile = temp_combo.tile;
17622
2/4
✓ Branch 0 taken 7666690 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7666690 times.
✗ Branch 3 not taken.
7666690 if(!p_getc(&temp_combo.flip,f))
17623 {
17624 return qe_invalid;
17625 }
17626
17627
2/4
✓ Branch 0 taken 7666690 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7666690 times.
✗ Branch 3 not taken.
7666690 if(!p_getc(&temp_combo.walk,f))
17628 {
17629 return qe_invalid;
17630 }
17631
17632
2/4
✓ Branch 0 taken 7666690 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7666690 times.
✗ Branch 3 not taken.
7666690 if(!p_getc(&temp_combo.type,f))
17633 {
17634 return qe_invalid;
17635 }
17636
17637
2/4
✓ Branch 0 taken 7666690 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7666690 times.
✗ Branch 3 not taken.
7666690 if(!p_getc(&temp_combo.csets,f))
17638 {
17639 return qe_invalid;
17640 }
17641
17642
2/2
✓ Branch 0 taken 69774 times.
✓ Branch 1 taken 7596916 times.
7666690 if(version < 0x193)
17643 {
17644
2/4
✓ Branch 0 taken 69774 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 69774 times.
✗ Branch 3 not taken.
69774 if(!p_getc(&padding,f))
17645 return qe_invalid;
17646
17647
2/4
✓ Branch 0 taken 69774 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 69774 times.
✗ Branch 3 not taken.
69774 if(!p_getc(&padding,f))
17648 return qe_invalid;
17649
17650
2/2
✓ Branch 0 taken 32910 times.
✓ Branch 1 taken 36864 times.
69774 if(version < 0x192)
17651 {
17652
1/2
✓ Branch 0 taken 36864 times.
✗ Branch 1 not taken.
36864 if(version == 0x191)
17653 {
17654 for(int32_t tmpcounter=0; tmpcounter<16; tmpcounter++)
17655 {
17656 if(!p_getc(&padding,f))
17657 return qe_invalid;
17658 }
17659 }
17660 36864 }
17661 69774 }
17662
2/2
✓ Branch 0 taken 7629826 times.
✓ Branch 1 taken 36864 times.
7666690 if(version >= 0x192)
17663 {
17664
2/4
✓ Branch 0 taken 7629826 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7629826 times.
✗ Branch 3 not taken.
7629826 if(!p_getc(&temp_combo.frames,f))
17665 return qe_invalid;
17666
17667
2/4
✓ Branch 0 taken 7629826 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7629826 times.
✗ Branch 3 not taken.
7629826 if(!p_getc(&temp_combo.speed,f))
17668 return qe_invalid;
17669
17670
2/4
✓ Branch 0 taken 7629826 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7629826 times.
✗ Branch 3 not taken.
7629826 if(!p_igetw(&temp_combo.nextcombo,f))
17671 return qe_invalid;
17672
17673
2/4
✓ Branch 0 taken 7629826 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7629826 times.
✗ Branch 3 not taken.
7629826 if(!p_getc(&temp_combo.nextcset,f))
17674 return qe_invalid;
17675
17676 //Base flag
17677
2/2
✓ Branch 0 taken 4741418 times.
✓ Branch 1 taken 2888408 times.
7629826 if(section_version>=3)
17678
2/4
✓ Branch 0 taken 4741418 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4741418 times.
✗ Branch 3 not taken.
4741418 if(!p_getc(&temp_combo.flag,f))
17679 return qe_invalid;
17680
17681
2/2
✓ Branch 0 taken 4741418 times.
✓ Branch 1 taken 2888408 times.
7629826 if(section_version>=4)
17682 {
17683
2/4
✓ Branch 0 taken 4741418 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4741418 times.
✗ Branch 3 not taken.
4741418 if(!p_getc(&temp_combo.skipanim,f))
17684 return qe_invalid;
17685
17686
2/4
✓ Branch 0 taken 4741418 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4741418 times.
✗ Branch 3 not taken.
4741418 if(!p_igetw(&temp_combo.nexttimer,f))
17687 return qe_invalid;
17688 4741418 }
17689
17690
2/2
✓ Branch 0 taken 4741418 times.
✓ Branch 1 taken 2888408 times.
7629826 if(section_version>=5)
17691
2/4
✓ Branch 0 taken 4741418 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4741418 times.
✗ Branch 3 not taken.
4741418 if(!p_getc(&temp_combo.skipanimy,f))
17692 return qe_invalid;
17693
17694
2/2
✓ Branch 0 taken 4741418 times.
✓ Branch 1 taken 2888408 times.
7629826 if(section_version>=6)
17695 {
17696
2/4
✓ Branch 0 taken 4741418 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4741418 times.
✗ Branch 3 not taken.
4741418 if(!p_getc(&temp_combo.animflags,f))
17697 return qe_invalid;
17698
17699
1/2
✓ Branch 0 taken 4741418 times.
✗ Branch 1 not taken.
4741418 if(section_version == 6)
17700 temp_combo.animflags = temp_combo.animflags ? AF_FRESH : 0;
17701 4741418 }
17702
17703
2/2
✓ Branch 0 taken 7426858 times.
✓ Branch 1 taken 202968 times.
7629826 if(section_version>=8) //combo Attributes[4] and userflags.
17704 {
17705
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 811872 times.
1014840 for ( int32_t q = 0; q < NUM_COMBO_ATTRIBUTES; q++ )
17706
2/4
✓ Branch 0 taken 811872 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 811872 times.
✗ Branch 3 not taken.
811872 if(!p_igetl(&temp_combo.attributes[q],f))
17707 return qe_invalid;
17708
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_igetl(&temp_combo.usrflags,f))
17709 return qe_invalid;
17710
1/2
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
202968 if(section_version >= 20)
17711
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_igetw(&temp_combo.genflags,f))
17712 return qe_invalid;
17713 202968 }
17714
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7426858 times.
7629826 if(section_version>=10) //combo trigger flags
17715 {
17716
2/2
✓ Branch 0 taken 608904 times.
✓ Branch 1 taken 202968 times.
811872 for ( int32_t q = 0; q < 3; q++ )
17717
2/4
✓ Branch 0 taken 608904 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 608904 times.
✗ Branch 3 not taken.
608904 if(!p_igetl(&temp_trigger.triggerflags[q],f))
17718 return qe_invalid;
17719 202968 }
17720
1/2
✓ Branch 0 taken 7426858 times.
✗ Branch 1 not taken.
7426858 else if(section_version==9) //combo trigger flags, V9 only had two indices of triggerflags[]
17721 {
17722 for ( int32_t q = 0; q < 2; q++ )
17723 if(!p_igetl(&temp_trigger.triggerflags[q],f))
17724 return qe_invalid;
17725 }
17726
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7426858 times.
7629826 if(section_version >= 9)
17727
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_igetl(&temp_trigger.triggerlevel,f))
17728 return qe_invalid;
17729
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7426858 times.
7629826 if(section_version >= 22)
17730
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_getc(&temp_trigger.triggerbtn,f))
17731 return qe_invalid;
17732
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7629826 times.
7629826 if(section_version >= 24)
17733 {
17734 if(!p_getc(&temp_trigger.triggeritem,f))
17735 return qe_invalid;
17736 if(!p_getc(&tempbyte, f))
17737 return qe_invalid;
17738 temp_trigger.trigtimer = tempbyte;
17739 }
17740
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7629826 times.
7629826 if(section_version >= 25)
17741 if(!p_getc(&temp_trigger.trigsfx,f))
17742 return qe_invalid;
17743
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7629826 times.
7629826 if(section_version >= 27)
17744 if(!p_igetl(&temp_trigger.trigchange,f))
17745 return qe_invalid;
17746
17747
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7629826 times.
7629826 if(section_version >= 29)
17748 {
17749 if(!p_igetw(&temp_trigger.trigprox,f))
17750 return qe_invalid;
17751 if(!p_getc(&tempbyte,f))
17752 return qe_invalid;
17753 temp_trigger.trigctr = tempbyte;
17754 if(!p_igetl(&temp_trigger.trigctramnt,f))
17755 return qe_invalid;
17756 }
17757
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7629826 times.
7629826 if(section_version >= 30)
17758 if(!p_getc(&temp_trigger.triglbeam,f))
17759 return qe_invalid;
17760
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7629826 times.
7629826 if(section_version >= 31)
17761 {
17762 if(!p_getc(&temp_trigger.trigcschange,f))
17763 return qe_invalid;
17764 if(!p_igetw(&temp_trigger.spawnitem,f))
17765 return qe_invalid;
17766 if(!p_igetw(&temp_trigger.spawnenemy,f))
17767 return qe_invalid;
17768 if(!p_getc(&temp_trigger.exstate,f))
17769 return qe_invalid;
17770 if(!p_igetl(&temp_trigger.spawnip,f))
17771 return qe_invalid;
17772 if(!p_getc(&temp_trigger.trigcopycat,f))
17773 return qe_invalid;
17774 }
17775
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7629826 times.
7629826 if(section_version >= 32)
17776 if(!p_getc(&temp_trigger.trigcooldown,f))
17777 return qe_invalid;
17778
17779
2/2
✓ Branch 0 taken 7426858 times.
✓ Branch 1 taken 202968 times.
7629826 if(section_version>=12) //combo label
17780 {
17781 char label[12];
17782 202968 label[11] = '\0';
17783
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 2232648 times.
2435616 for ( int32_t q = 0; q < 11; q++ )
17784
2/4
✓ Branch 0 taken 2232648 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2232648 times.
✗ Branch 3 not taken.
2232648 if(!p_getc(&label[q],f))
17785 return qe_invalid;
17786
1/2
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
202968 temp_combo.label = label;
17787 202968 }
17788
2/2
✓ Branch 0 taken 7426858 times.
✓ Branch 1 taken 202968 times.
7629826 if(section_version>=13) //attribytes[4]
17789
2/2
✓ Branch 0 taken 811872 times.
✓ Branch 1 taken 202968 times.
1014840 for ( int32_t q = 0; q < 4; q++ )
17790
2/4
✓ Branch 0 taken 811872 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 811872 times.
✗ Branch 3 not taken.
811872 if(!p_getc(&temp_combo.attribytes[q],f))
17791 202968 return qe_invalid;
17792 /* HIGHLY UNORTHODOX UPDATING THING, by Deedee
17793 * This fixes a poor implementation of a ->next flag bug thing.
17794 * Zoria didn't bump up the versions as liberally as he should have, but thankfully
17795 * there was a version bump a few weeks before a change that broke stuff.
17796 */
17797
3/4
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7426858 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 202968 times.
7629826 if (section_version >= 13 && section_version < 21)
17798 {
17799 set_qr(qr_BUGGY_BUGGY_SLASH_TRIGGERS,1);
17800 }
17801 //combo scripts
17802
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7426858 times.
7629826 if(section_version>=14)
17803 {
17804
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_igetw(&temp_combo.script,f))
17805 return qe_invalid;
17806
2/2
✓ Branch 0 taken 405936 times.
✓ Branch 1 taken 202968 times.
608904 for ( int32_t q = 0; q < 2; q++ )
17807
2/4
✓ Branch 0 taken 405936 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 405936 times.
✗ Branch 3 not taken.
405936 if(!p_igetl(&temp_combo.initd[q],f))
17808 return qe_invalid;
17809 202968 }
17810
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7426858 times.
7629826 if(section_version>=15)
17811 {
17812
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_igetl(&temp_combo.o_tile,f)) return qe_invalid;
17813
2/2
✓ Branch 0 taken 107633 times.
✓ Branch 1 taken 95335 times.
202968 if(!temp_combo.o_tile) temp_combo.o_tile = temp_combo.tile;
17814
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_getc(&temp_combo.cur_frame,f)) return qe_invalid;
17815
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_getc(&temp_combo.aclk,f)) return qe_invalid;
17816 202968 }
17817
2/2
✓ Branch 0 taken 7426858 times.
✓ Branch 1 taken 202968 times.
7629826 if(section_version>=17) //attribytes[4]
17818 {
17819
2/2
✓ Branch 0 taken 811872 times.
✓ Branch 1 taken 202968 times.
1014840 for ( int32_t q = 4; q < 8; q++ ) //bump up attribytes...
17820
2/4
✓ Branch 0 taken 811872 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 811872 times.
✗ Branch 3 not taken.
811872 if(!p_getc(&temp_combo.attribytes[q],f))
17821 return qe_invalid;
17822
2/2
✓ Branch 0 taken 1623744 times.
✓ Branch 1 taken 202968 times.
1826712 for ( int32_t q = 0; q < 8; q++ ) //...and add attrishorts
17823
2/4
✓ Branch 0 taken 1623744 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1623744 times.
✗ Branch 3 not taken.
1623744 if(!p_igetw(&temp_combo.attrishorts[q],f))
17824 return qe_invalid;
17825 202968 }
17826
17827
2/2
✓ Branch 0 taken 7596916 times.
✓ Branch 1 taken 32910 times.
7629826 if(version < 0x193)
17828
2/2
✓ Branch 0 taken 362010 times.
✓ Branch 1 taken 32910 times.
394920 for(int32_t q=0; q<11; q++)
17829
2/4
✓ Branch 0 taken 362010 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 362010 times.
✗ Branch 3 not taken.
362010 if(!p_getc(&dummy,f))
17830 32910 return qe_invalid;
17831 7629826 }
17832
17833 //Goriya tiles were flipped around in 2.11 build 7. Compensate for the flip here. -DD
17834
3/6
✓ Branch 0 taken 4741418 times.
✓ Branch 1 taken 2925272 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4741418 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7666690 if((version < 0x211)||((version == 0x211)&&(build<7)))
17835 {
17836
2/2
✓ Branch 0 taken 2885336 times.
✓ Branch 1 taken 39936 times.
2925272 if(!get_qr(qr_NEWENEMYTILES))
17837 {
17838
1/5
✓ Branch 0 taken 39936 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
39936 switch(temp_combo.tile)
17839 {
17840 case 130:
17841 temp_combo.tile = 132;
17842 break;
17843
17844 case 131:
17845 temp_combo.tile = 133;
17846 break;
17847
17848 case 132:
17849 temp_combo.tile = 130;
17850 break;
17851
17852 case 133:
17853 temp_combo.tile = 131;
17854 break;
17855 }
17856 39936 }
17857 2925272 }
17858
17859
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7463722 times.
7666690 if(section_version < 15)
17860 7463722 temp_combo.o_tile = temp_combo.tile;
17861
17862
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7463722 times.
7666690 if(section_version<18) //upper bits for .walk
17863 7463722 temp_combo.walk |= 0xF0;
17864
17865
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7463722 times.
7666690 if(section_version < 19)
17866
2/2
✓ Branch 0 taken 29854888 times.
✓ Branch 1 taken 7463722 times.
37318610 for(int32_t q = 0; q < 4; ++q)
17867 37318610 temp_combo.attributes[q] *= 10000L;
17868
17869
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7666690 times.
7666690 if(section_version < 23)
17870 {
17871
2/2
✓ Branch 0 taken 15359 times.
✓ Branch 1 taken 7651331 times.
7666690 switch(temp_combo.type) //combotriggerCMBTYPEFX now required for combotype-specific effects
17872 {
17873 case cSCRIPT1: case cSCRIPT2: case cSCRIPT3: case cSCRIPT4: case cSCRIPT5:
17874 case cSCRIPT6: case cSCRIPT7: case cSCRIPT8: case cSCRIPT9: case cSCRIPT10:
17875 case cTRIGGERGENERIC: case cCSWITCH:
17876 15359 temp_trigger.triggerflags[0] |= combotriggerCMBTYPEFX;
17877 15359 }
17878 7666690 }
17879
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7666690 times.
7666690 if(section_version < 25)
17880 {
17881
2/2
✓ Branch 0 taken 27600 times.
✓ Branch 1 taken 7639090 times.
7666690 switch(temp_combo.type)
17882 {
17883 case cLOCKBLOCK: case cBOSSLOCKBLOCK:
17884
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27600 times.
27600 if(!(temp_combo.usrflags & cflag3))
17885 27600 temp_combo.attribytes[3] = WAV_DOOR;
17886 27600 temp_combo.usrflags &= ~cflag3;
17887 27600 break;
17888 }
17889 7666690 }
17890
17891
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7666690 times.
7666690 if(section_version < 26)
17892
2/2
✓ Branch 0 taken 7665547 times.
✓ Branch 1 taken 1143 times.
7667833 if(temp_combo.type == cARMOS)
17893
1/2
✓ Branch 0 taken 1143 times.
✗ Branch 1 not taken.
1143 if(temp_combo.usrflags & cflag1)
17894 temp_combo.usrflags |= cflag3;
17895
17896
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7666690 times.
7666690 if(section_version < 27)
17897 {
17898
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7666690 times.
7666690 if(temp_trigger.triggerflags[0] & 0x00040000) //'next'
17899 temp_trigger.trigchange = 1;
17900
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7666690 times.
7666690 else if(temp_trigger.triggerflags[0] & 0x00080000) //'prev'
17901 temp_trigger.trigchange = -1;
17902 7666690 else temp_trigger.trigchange = 0;
17903 7666690 temp_trigger.triggerflags[0] &= ~(0x00040000|0x00080000);
17904 7666690 }
17905
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7666690 times.
7666690 if(section_version < 28)
17906 {
17907
2/2
✓ Branch 0 taken 15669 times.
✓ Branch 1 taken 7651021 times.
7666690 switch(temp_combo.type)
17908 {
17909 case cLOCKBLOCK: case cLOCKEDCHEST:
17910
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15669 times.
15669 if(temp_combo.usrflags & cflag7)
17911 temp_combo.usrflags |= cflag8;
17912 15669 else temp_combo.usrflags &= ~cflag8;
17913 15669 temp_combo.usrflags &= ~cflag7;
17914 15669 break;
17915 }
17916
2/2
✓ Branch 0 taken 782 times.
✓ Branch 1 taken 7665908 times.
7666690 switch(temp_combo.type)
17917 {
17918 case cCHEST: case cLOCKEDCHEST: case cBOSSCHEST:
17919 782 temp_combo.attrishorts[2] = -1;
17920 782 temp_combo.usrflags |= cflag7;
17921 782 break;
17922 }
17923 7666690 }
17924
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7463722 times.
7666690 if(section_version < 20)
17925 {
17926 7463722 temp_combo.genflags = 0;
17927
2/2
✓ Branch 0 taken 144658 times.
✓ Branch 1 taken 7319064 times.
7463722 switch(temp_combo.type)
17928 {
17929 case cPUSH_WAIT: case cPUSH_HEAVY:
17930 case cPUSH_HW: case cL_STATUE:
17931 case cR_STATUE: case cPUSH_HEAVY2:
17932 case cPUSH_HW2: case cPOUND:
17933 case cC_STATUE: case cMIRROR:
17934 case cMIRRORSLASH: case cMIRRORBACKSLASH:
17935 case cMAGICPRISM: case cMAGICPRISM4:
17936 case cMAGICSPONGE: case cEYEBALL_A:
17937 case cEYEBALL_B: case cEYEBALL_4:
17938 case cBUSH: case cFLOWERS:
17939 case cLOCKBLOCK: case cLOCKBLOCK2:
17940 case cBOSSLOCKBLOCK: case cBOSSLOCKBLOCK2:
17941 case cCHEST: case cCHEST2:
17942 case cLOCKEDCHEST: case cLOCKEDCHEST2:
17943 case cBOSSCHEST: case cBOSSCHEST2:
17944 case cBUSHNEXT: case cBUSHTOUCHY:
17945 case cFLOWERSTOUCHY: case cBUSHNEXTTOUCHY:
17946 case cSIGNPOST: case cCSWITCHBLOCK:
17947 case cTORCH: case cTRIGGERGENERIC:
17948
1/2
✓ Branch 0 taken 144658 times.
✗ Branch 1 not taken.
144658 if(temp_combo.usrflags & cflag16)
17949 {
17950 temp_combo.genflags |= cflag1;
17951 temp_combo.usrflags &= ~cflag16;
17952 }
17953 144658 break;
17954 }
17955 7463722 }
17956
17957
3/4
✓ Branch 0 taken 7666690 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15398 times.
✓ Branch 3 taken 7651292 times.
7666690 if(temp_trigger.is_blank())
17958 7651292 temp_combo.triggers.clear();
17959
17960 7666690 update_combo(temp_combo, section_version);
17961
17962
3/4
✓ Branch 0 taken 7666690 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7651771 times.
✓ Branch 3 taken 14919 times.
7666690 if(i>=start_combo && !should_skip)
17963 {
17964
1/2
✓ Branch 0 taken 7651771 times.
✗ Branch 1 not taken.
7651771 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
17965 {
17966 temp_combo.script = 0;
17967 for(int q = 0; q < 8; ++q)
17968 temp_combo.initd[q] = 0;
17969 }
17970
1/2
✓ Branch 0 taken 7651771 times.
✗ Branch 1 not taken.
7651771 combobuf[i] = temp_combo;
17971 7651771 }
17972 7666690 }
17973
17974
2/2
✓ Branch 0 taken 293 times.
✓ Branch 1 taken 1 times.
294 if (should_skip)
17975 1 return 0;
17976
17977
5/6
✓ Branch 0 taken 275 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 270 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
293 if((version < 0x192)|| ((version == 0x192)&&(build<185)))
17978 {
17979
2/2
✓ Branch 0 taken 1501440 times.
✓ Branch 1 taken 23 times.
1501463 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
17980 {
17981
2/2
✓ Branch 0 taken 1501225 times.
✓ Branch 1 taken 215 times.
1501440 if(combobuf[tmpcounter].type==cHOOKSHOTONLY)
17982 {
17983 215 combobuf[tmpcounter].type=cLADDERHOOKSHOT;
17984 215 }
17985 1501440 }
17986 23 }
17987
17988 //June 3 2012; ladder only is broken in 2.10 and allows the hookshot also. -Gleeok
17989
4/6
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 234 times.
✓ Branch 2 taken 59 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 59 times.
293 if(version == 0x210 && get_app_id() != App::zquest)
17990 {
17991
2/2
✓ Branch 0 taken 3851520 times.
✓ Branch 1 taken 59 times.
3851579 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
17992
2/2
✓ Branch 0 taken 3851335 times.
✓ Branch 1 taken 185 times.
3851705 if(combobuf[tmpcounter].type == cLADDERONLY)
17993 185 combobuf[tmpcounter].type = cLADDERHOOKSHOT;
17994 59 }
17995
17996
2/2
✓ Branch 0 taken 211 times.
✓ Branch 1 taken 82 times.
293 if(section_version<7)
17997 {
17998
2/2
✓ Branch 0 taken 5352960 times.
✓ Branch 1 taken 82 times.
5353042 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
17999 {
18000
6/9
✓ Branch 0 taken 5350008 times.
✓ Branch 1 taken 853 times.
✓ Branch 2 taken 791 times.
✓ Branch 3 taken 603 times.
✓ Branch 4 taken 174 times.
✓ Branch 5 taken 531 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
5352960 switch(combobuf[tmpcounter].type)
18001 {
18002 case cSLASH:
18003 853 combobuf[tmpcounter].type=cSLASHTOUCHY;
18004 853 break;
18005
18006 case cSLASHITEM:
18007 791 combobuf[tmpcounter].type=cSLASHITEMTOUCHY;
18008 791 break;
18009
18010 case cBUSH:
18011 603 combobuf[tmpcounter].type=cBUSHTOUCHY;
18012 603 break;
18013
18014 case cFLOWERS:
18015 174 combobuf[tmpcounter].type=cFLOWERSTOUCHY;
18016 174 break;
18017
18018 case cTALLGRASS:
18019 531 combobuf[tmpcounter].type=cTALLGRASSTOUCHY;
18020 531 break;
18021
18022 case cSLASHNEXT:
18023 combobuf[tmpcounter].type=cSLASHNEXTTOUCHY;
18024 break;
18025
18026 case cSLASHNEXTITEM:
18027 combobuf[tmpcounter].type=cSLASHNEXTITEMTOUCHY;
18028 break;
18029
18030 case cBUSHNEXT:
18031 combobuf[tmpcounter].type=cBUSHNEXTTOUCHY;
18032 break;
18033 }
18034 5352960 }
18035 82 }
18036
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 288 times.
293 if (section_version < 16)
18037 {
18038
2/2
✓ Branch 0 taken 18800640 times.
✓ Branch 1 taken 288 times.
18800928 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
18039 {
18040
2/2
✓ Branch 0 taken 18771349 times.
✓ Branch 1 taken 29291 times.
18800640 if (combobuf[tmpcounter].type == cWATER)
18041 {
18042 29291 combobuf[tmpcounter].attributes[0] = 40000L;
18043 29291 }
18044 18800640 }
18045 288 }
18046
2/2
✓ Branch 0 taken 290 times.
✓ Branch 1 taken 3 times.
293 if(!get_qr(qr_ALLOW_EDITING_COMBO_0))
18047 {
18048 3 combobuf[0].walk = 0xF0;
18049 3 combobuf[0].type = 0;
18050 3 combobuf[0].flag = 0;
18051 3 }
18052
18053 //Now for the new combo alias reset
18054
2/2
✓ Branch 0 taken 211 times.
✓ Branch 1 taken 82 times.
293 if(section_version<2)
18055 {
18056
2/2
✓ Branch 0 taken 671744 times.
✓ Branch 1 taken 82 times.
671826 for(int32_t j=0; j<MAXCOMBOALIASES; j++)
18057 {
18058 671744 combo_aliases[j].width = 0;
18059 671744 combo_aliases[j].height = 0;
18060 671744 combo_aliases[j].layermask = 0;
18061
1/2
✓ Branch 0 taken 671744 times.
✗ Branch 1 not taken.
671744 combo_aliases[j].combos.clear();
18062
1/2
✓ Branch 0 taken 671744 times.
✗ Branch 1 not taken.
671744 combo_aliases[j].csets.clear();
18063 671744 }
18064 82 }
18065
18066
18067
1/2
✓ Branch 0 taken 293 times.
✗ Branch 1 not taken.
293 setup_combo_animations();
18068
1/2
✓ Branch 0 taken 293 times.
✗ Branch 1 not taken.
293 setup_combo_animations2();
18069 293 return 0;
18070 294 }
18071
18072 12679 int32_t readcombo_triggers_loop(PACKFILE* f, word s_version, combo_trigger& temp_trigger)
18073 {
18074 byte tempbyte;
18075
2/2
✓ Branch 0 taken 7621 times.
✓ Branch 1 taken 5058 times.
12679 if(s_version >= 52)
18076
1/2
✓ Branch 0 taken 5058 times.
✗ Branch 1 not taken.
5058 if(!p_getcstr(&temp_trigger.label,f))
18077 return qe_invalid;
18078
18079 12679 int numtrigs = s_version < 36 ? 3 : 6;
18080
2/2
✓ Branch 0 taken 75216 times.
✓ Branch 1 taken 12679 times.
87895 for ( int32_t q = 0; q < numtrigs; q++ )
18081
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 75216 times.
75216 if(!p_igetl(&temp_trigger.triggerflags[q],f))
18082 return qe_invalid;
18083
1/2
✓ Branch 0 taken 12679 times.
✗ Branch 1 not taken.
12679 if(!p_igetl(&temp_trigger.triggerlevel,f))
18084 return qe_invalid;
18085
1/2
✓ Branch 0 taken 12679 times.
✗ Branch 1 not taken.
12679 if(!p_getc(&temp_trigger.triggerbtn,f))
18086 return qe_invalid;
18087
1/2
✓ Branch 0 taken 12679 times.
✗ Branch 1 not taken.
12679 if(!p_getc(&temp_trigger.triggeritem,f))
18088 return qe_invalid;
18089
2/2
✓ Branch 0 taken 5058 times.
✓ Branch 1 taken 7621 times.
12679 if(s_version >= 53)
18090 {
18091
1/2
✓ Branch 0 taken 5058 times.
✗ Branch 1 not taken.
5058 if(!p_igetw(&temp_trigger.trigtimer,f))
18092 return qe_invalid;
18093 5058 }
18094 else
18095 {
18096
1/2
✓ Branch 0 taken 7621 times.
✗ Branch 1 not taken.
7621 if(!p_getc(&tempbyte, f))
18097 return qe_invalid;
18098 7621 temp_trigger.trigtimer = tempbyte;
18099 }
18100
1/2
✓ Branch 0 taken 12679 times.
✗ Branch 1 not taken.
12679 if(!p_getc(&temp_trigger.trigsfx,f))
18101 return qe_invalid;
18102
1/2
✓ Branch 0 taken 12679 times.
✗ Branch 1 not taken.
12679 if(!p_igetl(&temp_trigger.trigchange,f))
18103 return qe_invalid;
18104
1/2
✓ Branch 0 taken 12679 times.
✗ Branch 1 not taken.
12679 if(!p_igetw(&temp_trigger.trigprox,f))
18105 return qe_invalid;
18106
2/2
✓ Branch 0 taken 5058 times.
✓ Branch 1 taken 7621 times.
12679 if(s_version >= 53)
18107 {
18108
1/2
✓ Branch 0 taken 5058 times.
✗ Branch 1 not taken.
5058 if(!p_igetw(&temp_trigger.trigctr,f))
18109 return qe_invalid;
18110 5058 }
18111 else
18112 {
18113
1/2
✓ Branch 0 taken 7621 times.
✗ Branch 1 not taken.
7621 if(!p_getc(&tempbyte,f))
18114 return qe_invalid;
18115 7621 temp_trigger.trigctr = tempbyte;
18116 }
18117
1/2
✓ Branch 0 taken 12679 times.
✗ Branch 1 not taken.
12679 if(!p_igetl(&temp_trigger.trigctramnt,f))
18118 return qe_invalid;
18119
1/2
✓ Branch 0 taken 12679 times.
✗ Branch 1 not taken.
12679 if(!p_getc(&temp_trigger.triglbeam,f))
18120 return qe_invalid;
18121
1/2
✓ Branch 0 taken 12679 times.
✗ Branch 1 not taken.
12679 if(!p_getc(&temp_trigger.trigcschange,f))
18122 return qe_invalid;
18123
1/2
✓ Branch 0 taken 12679 times.
✗ Branch 1 not taken.
12679 if(!p_igetw(&temp_trigger.spawnitem,f))
18124 return qe_invalid;
18125
1/2
✓ Branch 0 taken 12679 times.
✗ Branch 1 not taken.
12679 if(!p_igetw(&temp_trigger.spawnenemy,f))
18126 return qe_invalid;
18127
1/2
✓ Branch 0 taken 12679 times.
✗ Branch 1 not taken.
12679 if(!p_getc(&temp_trigger.exstate,f))
18128 return qe_invalid;
18129
1/2
✓ Branch 0 taken 12679 times.
✗ Branch 1 not taken.
12679 if(!p_igetl(&temp_trigger.spawnip,f))
18130 return qe_invalid;
18131
1/2
✓ Branch 0 taken 12679 times.
✗ Branch 1 not taken.
12679 if(!p_getc(&temp_trigger.trigcopycat,f))
18132 return qe_invalid;
18133
1/2
✓ Branch 0 taken 12679 times.
✗ Branch 1 not taken.
12679 if(!p_getc(&temp_trigger.trigcooldown,f))
18134 return qe_invalid;
18135
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12679 times.
12679 if(s_version >= 35)
18136 {
18137
1/2
✓ Branch 0 taken 12679 times.
✗ Branch 1 not taken.
12679 if(!p_igetw(&temp_trigger.prompt_cid,f))
18138 return qe_invalid;
18139
1/2
✓ Branch 0 taken 12679 times.
✗ Branch 1 not taken.
12679 if(!p_getc(&temp_trigger.prompt_cs,f))
18140 return qe_invalid;
18141
1/2
✓ Branch 0 taken 12679 times.
✗ Branch 1 not taken.
12679 if(!p_igetw(&temp_trigger.prompt_x,f))
18142 return qe_invalid;
18143
1/2
✓ Branch 0 taken 12679 times.
✗ Branch 1 not taken.
12679 if(!p_igetw(&temp_trigger.prompt_y,f))
18144 return qe_invalid;
18145 12679 }
18146
2/2
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 12393 times.
12679 if(s_version >= 36)
18147 {
18148
1/2
✓ Branch 0 taken 12393 times.
✗ Branch 1 not taken.
12393 if(!p_getc(&temp_trigger.trig_lstate,f))
18149 return qe_invalid;
18150
1/2
✓ Branch 0 taken 12393 times.
✗ Branch 1 not taken.
12393 if(!p_getc(&temp_trigger.trig_gstate,f))
18151 return qe_invalid;
18152
1/2
✓ Branch 0 taken 12393 times.
✗ Branch 1 not taken.
12393 if(!p_igetl(&temp_trigger.trig_statetime,f))
18153 return qe_invalid;
18154 12393 }
18155
2/2
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 12393 times.
12679 if(s_version >= 37)
18156 {
18157
1/2
✓ Branch 0 taken 12393 times.
✗ Branch 1 not taken.
12393 if(!p_igetw(&temp_trigger.trig_genscr,f))
18158 return qe_invalid;
18159 12393 }
18160
2/2
✓ Branch 0 taken 434 times.
✓ Branch 1 taken 12245 times.
12679 if(s_version >= 38)
18161 {
18162
1/2
✓ Branch 0 taken 12245 times.
✗ Branch 1 not taken.
12245 if(!p_getc(&temp_trigger.trig_group,f))
18163 return qe_invalid;
18164
1/2
✓ Branch 0 taken 12245 times.
✗ Branch 1 not taken.
12245 if(!p_igetw(&temp_trigger.trig_group_val,f))
18165 return qe_invalid;
18166 12245 }
18167
2/2
✓ Branch 0 taken 470 times.
✓ Branch 1 taken 12209 times.
12679 if(s_version >= 45)
18168 {
18169
1/2
✓ Branch 0 taken 12209 times.
✗ Branch 1 not taken.
12209 if(!p_getc(&temp_trigger.exdoor_dir,f))
18170 return qe_invalid;
18171
1/2
✓ Branch 0 taken 12209 times.
✗ Branch 1 not taken.
12209 if(!p_getc(&temp_trigger.exdoor_ind,f))
18172 return qe_invalid;
18173 12209 }
18174
2/2
✓ Branch 0 taken 7112 times.
✓ Branch 1 taken 5567 times.
12679 if(s_version >= 46)
18175 {
18176
1/2
✓ Branch 0 taken 5567 times.
✗ Branch 1 not taken.
5567 if(!p_getc(&temp_trigger.trig_levelitems,f))
18177 return qe_invalid;
18178
1/2
✓ Branch 0 taken 5567 times.
✗ Branch 1 not taken.
5567 if(!p_igetw(&temp_trigger.trigdmlevel,f))
18179 return qe_invalid;
18180
1/2
✓ Branch 0 taken 5567 times.
✗ Branch 1 not taken.
5567 if(s_version >= 48)
18181 {
18182
2/2
✓ Branch 0 taken 16701 times.
✓ Branch 1 taken 5567 times.
22268 for(int q = 0; q < 3; ++q)
18183
1/2
✓ Branch 0 taken 16701 times.
✗ Branch 1 not taken.
16701 if(!p_igetw(&temp_trigger.trigtint[q],f))
18184 return qe_invalid;
18185 5567 }
18186 else
18187 {
18188 for(int q = 0; q < 3; ++q)
18189 if(!p_getc(&temp_trigger.trigtint[q],f))
18190 return qe_invalid;
18191 for(int q = 0; q < 3; ++q)
18192 {
18193 int v = temp_trigger.trigtint[q];
18194 int va = abs(v);
18195 temp_trigger.trigtint[q] = _rgb_scale_6[va] * sign(v);
18196 }
18197 }
18198
1/2
✓ Branch 0 taken 5567 times.
✗ Branch 1 not taken.
5567 if(!p_igetw(&temp_trigger.triglvlpalette,f))
18199 return qe_invalid;
18200
1/2
✓ Branch 0 taken 5567 times.
✗ Branch 1 not taken.
5567 if(!p_igetw(&temp_trigger.trigbosspalette,f))
18201 return qe_invalid;
18202
1/2
✓ Branch 0 taken 5567 times.
✗ Branch 1 not taken.
5567 if(!p_igetw(&temp_trigger.trigquaketime,f))
18203 return qe_invalid;
18204
1/2
✓ Branch 0 taken 5567 times.
✗ Branch 1 not taken.
5567 if(!p_igetw(&temp_trigger.trigwavytime,f))
18205 return qe_invalid;
18206
1/2
✓ Branch 0 taken 5567 times.
✗ Branch 1 not taken.
5567 if(!p_igetw(&temp_trigger.trig_swjinxtime,f))
18207 return qe_invalid;
18208
1/2
✓ Branch 0 taken 5567 times.
✗ Branch 1 not taken.
5567 if(!p_igetw(&temp_trigger.trig_itmjinxtime,f))
18209 return qe_invalid;
18210
1/2
✓ Branch 0 taken 5567 times.
✗ Branch 1 not taken.
5567 if(!p_igetw(&temp_trigger.trig_stuntime,f))
18211 return qe_invalid;
18212
1/2
✓ Branch 0 taken 5567 times.
✗ Branch 1 not taken.
5567 if(!p_igetw(&temp_trigger.trig_bunnytime,f))
18213 return qe_invalid;
18214
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5567 times.
5567 if(!p_getc(&temp_trigger.trig_pushtime,f))
18215 return qe_invalid;
18216 5567 }
18217
2/2
✓ Branch 0 taken 7112 times.
✓ Branch 1 taken 5567 times.
12679 if(s_version >= 47)
18218 {
18219
1/2
✓ Branch 0 taken 5567 times.
✗ Branch 1 not taken.
5567 if (!p_igetw(&temp_trigger.trig_shieldjinxtime, f))
18220 return qe_invalid;
18221 5567 }
18222
2/2
✓ Branch 0 taken 5058 times.
✓ Branch 1 taken 7621 times.
12679 if(s_version >= 53)
18223 {
18224
1/2
✓ Branch 0 taken 5058 times.
✗ Branch 1 not taken.
5058 if(!p_igetl(&temp_trigger.req_level_state, f))
18225 return qe_invalid;
18226
1/2
✓ Branch 0 taken 5058 times.
✗ Branch 1 not taken.
5058 if(!p_igetl(&temp_trigger.unreq_level_state, f))
18227 return qe_invalid;
18228
1/2
✓ Branch 0 taken 5058 times.
✗ Branch 1 not taken.
5058 if(!p_getbitstr(&temp_trigger.req_global_state, f))
18229 return qe_invalid;
18230
1/2
✓ Branch 0 taken 5058 times.
✗ Branch 1 not taken.
5058 if(!p_getbitstr(&temp_trigger.unreq_global_state, f))
18231 return qe_invalid;
18232
1/2
✓ Branch 0 taken 5058 times.
✗ Branch 1 not taken.
5058 if(!p_igetw(&temp_trigger.fail_prompt_cid,f))
18233 return qe_invalid;
18234
1/2
✓ Branch 0 taken 5058 times.
✗ Branch 1 not taken.
5058 if(!p_getc(&temp_trigger.fail_prompt_cs,f))
18235 return qe_invalid;
18236
1/2
✓ Branch 0 taken 5058 times.
✗ Branch 1 not taken.
5058 if(!p_igetl(&temp_trigger.trig_msgstr, f))
18237 return qe_invalid;
18238
1/2
✓ Branch 0 taken 5058 times.
✗ Branch 1 not taken.
5058 if(!p_igetl(&temp_trigger.fail_msgstr, f))
18239 return qe_invalid;
18240
1/2
✓ Branch 0 taken 5058 times.
✗ Branch 1 not taken.
5058 if(!p_igetzf(&temp_trigger.player_bounce, f))
18241 return qe_invalid;
18242
1/2
✓ Branch 0 taken 5058 times.
✗ Branch 1 not taken.
5058 if(!p_igetzf(&temp_trigger.req_player_z, f))
18243 return qe_invalid;
18244 5058 }
18245 else
18246 {
18247 7621 temp_trigger.fail_prompt_cid = temp_trigger.prompt_cid;
18248 7621 temp_trigger.fail_prompt_cs = temp_trigger.prompt_cs;
18249 }
18250
2/2
✓ Branch 0 taken 7867 times.
✓ Branch 1 taken 4812 times.
12679 if(s_version >= 54)
18251 {
18252
1/2
✓ Branch 0 taken 4812 times.
✗ Branch 1 not taken.
4812 if(!p_getc(&temp_trigger.req_player_dir,f))
18253 return qe_invalid;
18254
1/2
✓ Branch 0 taken 4812 times.
✗ Branch 1 not taken.
4812 if(!p_igetzf(&temp_trigger.dest_player_x, f))
18255 return qe_invalid;
18256
1/2
✓ Branch 0 taken 4812 times.
✗ Branch 1 not taken.
4812 if(!p_igetzf(&temp_trigger.dest_player_y, f))
18257 return qe_invalid;
18258
1/2
✓ Branch 0 taken 4812 times.
✗ Branch 1 not taken.
4812 if(!p_igetzf(&temp_trigger.dest_player_z, f))
18259 return qe_invalid;
18260
1/2
✓ Branch 0 taken 4812 times.
✗ Branch 1 not taken.
4812 if(!p_igetzf(&temp_trigger.req_player_jump, f))
18261 return qe_invalid;
18262
1/2
✓ Branch 0 taken 4812 times.
✗ Branch 1 not taken.
4812 if(!p_igetzf(&temp_trigger.req_player_x, f))
18263 return qe_invalid;
18264
1/2
✓ Branch 0 taken 4812 times.
✗ Branch 1 not taken.
4812 if(!p_igetzf(&temp_trigger.req_player_y, f))
18265 return qe_invalid;
18266 4812 }
18267
2/2
✓ Branch 0 taken 9917 times.
✓ Branch 1 taken 2762 times.
12679 if(s_version >= 56)
18268 {
18269
1/2
✓ Branch 0 taken 2762 times.
✗ Branch 1 not taken.
2762 if(!p_getc(&temp_trigger.dest_player_dir, f))
18270 return qe_invalid;
18271
1/2
✓ Branch 0 taken 2762 times.
✗ Branch 1 not taken.
2762 if(!p_igetl(&temp_trigger.force_ice_combo, f))
18272 return qe_invalid;
18273
1/2
✓ Branch 0 taken 2762 times.
✗ Branch 1 not taken.
2762 if(!p_igetzf(&temp_trigger.force_ice_vx, f))
18274 return qe_invalid;
18275
1/2
✓ Branch 0 taken 2762 times.
✗ Branch 1 not taken.
2762 if(!p_igetzf(&temp_trigger.force_ice_vy, f))
18276 return qe_invalid;
18277 2762 }
18278 12679 return 0;
18279 12679 }
18280
18281 1464929 int32_t readcombo_loop(PACKFILE* f, word s_version, newcombo& temp_combo)
18282 {
18283 byte tempbyte;
18284 word combo_has_flags;
18285
2/2
✓ Branch 0 taken 659309 times.
✓ Branch 1 taken 805620 times.
1464929 if(s_version < 55)
18286 {
18287
1/2
✓ Branch 0 taken 659309 times.
✗ Branch 1 not taken.
659309 if(!p_getc(&tempbyte,f))
18288 return qe_invalid;
18289 659309 combo_has_flags = tempbyte;
18290 659309 }
18291 else
18292 {
18293
1/2
✓ Branch 0 taken 805620 times.
✗ Branch 1 not taken.
805620 if(!p_igetw(&combo_has_flags,f))
18294 return qe_invalid;
18295 }
18296
18297 1464929 temp_combo.clear();
18298
2/2
✓ Branch 0 taken 309311 times.
✓ Branch 1 taken 1155618 times.
1464929 if(combo_has_flags)
18299 {
18300
2/2
✓ Branch 0 taken 496441 times.
✓ Branch 1 taken 659177 times.
1155618 if(combo_has_flags&CHAS_BASIC)
18301 {
18302
1/2
✓ Branch 0 taken 659177 times.
✗ Branch 1 not taken.
659177 if(!p_igetl(&temp_combo.tile,f))
18303 return qe_invalid;
18304 659177 temp_combo.o_tile = temp_combo.tile;
18305
18306
1/2
✓ Branch 0 taken 659177 times.
✗ Branch 1 not taken.
659177 if(!p_getc(&temp_combo.flip,f))
18307 return qe_invalid;
18308
18309
1/2
✓ Branch 0 taken 659177 times.
✗ Branch 1 not taken.
659177 if(!p_getc(&temp_combo.walk,f))
18310 return qe_invalid;
18311
18312
1/2
✓ Branch 0 taken 659177 times.
✗ Branch 1 not taken.
659177 if(!p_getc(&temp_combo.type,f))
18313 return qe_invalid;
18314
18315
1/2
✓ Branch 0 taken 659177 times.
✗ Branch 1 not taken.
659177 if(!p_getc(&temp_combo.flag,f))
18316 return qe_invalid;
18317
18318
1/2
✓ Branch 0 taken 659177 times.
✗ Branch 1 not taken.
659177 if(!p_getc(&temp_combo.csets,f))
18319 return qe_invalid;
18320 659177 }
18321
2/2
✓ Branch 0 taken 1152763 times.
✓ Branch 1 taken 2855 times.
1155618 if(combo_has_flags&CHAS_SCRIPT)
18322 {
18323
2/2
✓ Branch 0 taken 2825 times.
✓ Branch 1 taken 30 times.
2855 if (s_version>=41)
18324 {
18325 2825 p_getcstr(&temp_combo.label, f);
18326 2825 }
18327 else
18328 {
18329 char label[12];
18330 30 label[11] = '\0';
18331
2/2
✓ Branch 0 taken 330 times.
✓ Branch 1 taken 30 times.
360 for ( int32_t q = 0; q < 11; q++ )
18332
1/2
✓ Branch 0 taken 330 times.
✗ Branch 1 not taken.
330 if(!p_getc(&label[q],f))
18333 return qe_invalid;
18334 30 temp_combo.label = label;
18335 }
18336
18337
1/2
✓ Branch 0 taken 2855 times.
✗ Branch 1 not taken.
2855 if(!p_igetw(&temp_combo.script,f)) return qe_invalid;
18338 2855 auto initd_count = s_version >= 43 ? 8 : 2;
18339
2/2
✓ Branch 0 taken 22660 times.
✓ Branch 1 taken 2855 times.
25515 for ( int32_t q = 0; q < initd_count; q++ )
18340
1/2
✓ Branch 0 taken 22660 times.
✗ Branch 1 not taken.
22660 if(!p_igetl(&temp_combo.initd[q],f))
18341 return qe_invalid;
18342 2855 }
18343
2/2
✓ Branch 0 taken 1029856 times.
✓ Branch 1 taken 125762 times.
1155618 if(combo_has_flags&CHAS_ANIM)
18344 {
18345
1/2
✓ Branch 0 taken 125762 times.
✗ Branch 1 not taken.
125762 if(!p_getc(&temp_combo.frames,f))
18346 return qe_invalid;
18347
18348
1/2
✓ Branch 0 taken 125762 times.
✗ Branch 1 not taken.
125762 if(!p_getc(&temp_combo.speed,f))
18349 return qe_invalid;
18350
18351
1/2
✓ Branch 0 taken 125762 times.
✗ Branch 1 not taken.
125762 if(!p_igetw(&temp_combo.nextcombo,f))
18352 return qe_invalid;
18353
18354
1/2
✓ Branch 0 taken 125762 times.
✗ Branch 1 not taken.
125762 if(!p_getc(&temp_combo.nextcset,f))
18355 return qe_invalid;
18356
18357
1/2
✓ Branch 0 taken 125762 times.
✗ Branch 1 not taken.
125762 if(!p_getc(&temp_combo.skipanim,f))
18358 return qe_invalid;
18359
18360
1/2
✓ Branch 0 taken 125762 times.
✗ Branch 1 not taken.
125762 if(!p_getc(&temp_combo.skipanimy,f))
18361 return qe_invalid;
18362
18363
1/2
✓ Branch 0 taken 125762 times.
✗ Branch 1 not taken.
125762 if(!p_getc(&temp_combo.animflags,f))
18364 return qe_invalid;
18365 125762 }
18366
2/2
✓ Branch 0 taken 1099855 times.
✓ Branch 1 taken 55763 times.
1155618 if(combo_has_flags&CHAS_ATTRIB)
18367 {
18368
2/2
✓ Branch 0 taken 223052 times.
✓ Branch 1 taken 55763 times.
278815 for ( int32_t q = 0; q < 4; q++ )
18369
1/2
✓ Branch 0 taken 223052 times.
✗ Branch 1 not taken.
223052 if(!p_igetl(&temp_combo.attributes[q],f))
18370 return qe_invalid;
18371
2/2
✓ Branch 0 taken 446104 times.
✓ Branch 1 taken 55763 times.
501867 for ( int32_t q = 0; q < 8; q++ )
18372
1/2
✓ Branch 0 taken 446104 times.
✗ Branch 1 not taken.
446104 if(!p_getc(&temp_combo.attribytes[q],f))
18373 return qe_invalid;
18374
2/2
✓ Branch 0 taken 446104 times.
✓ Branch 1 taken 55763 times.
501867 for ( int32_t q = 0; q < 8; q++ )
18375
1/2
✓ Branch 0 taken 446104 times.
✗ Branch 1 not taken.
446104 if(!p_igetw(&temp_combo.attrishorts[q],f))
18376 return qe_invalid;
18377 55763 }
18378
2/2
✓ Branch 0 taken 1143561 times.
✓ Branch 1 taken 12057 times.
1155618 if(combo_has_flags&CHAS_FLAG)
18379 {
18380
1/2
✓ Branch 0 taken 12057 times.
✗ Branch 1 not taken.
12057 if(!p_igetl(&temp_combo.usrflags,f))
18381 return qe_invalid;
18382
1/2
✓ Branch 0 taken 12057 times.
✗ Branch 1 not taken.
12057 if(!p_igetw(&temp_combo.genflags,f))
18383 return qe_invalid;
18384 12057 }
18385
2/2
✓ Branch 0 taken 1143002 times.
✓ Branch 1 taken 12616 times.
1155618 if(combo_has_flags&CHAS_TRIG)
18386 {
18387 12616 byte count = 1;
18388
2/2
✓ Branch 0 taken 7621 times.
✓ Branch 1 taken 4995 times.
12616 if(s_version >= 52)
18389
1/2
✓ Branch 0 taken 4995 times.
✗ Branch 1 not taken.
4995 if(!p_getc(&count, f))
18390 return qe_invalid;
18391
18392
2/2
✓ Branch 0 taken 12679 times.
✓ Branch 1 taken 12616 times.
25295 for(byte q = 0; q < count; ++q)
18393 {
18394 12679 combo_trigger& temp_trigger = temp_combo.triggers.emplace_back();
18395 12679 auto ret = readcombo_triggers_loop(f, s_version, temp_trigger);
18396
1/2
✓ Branch 0 taken 12679 times.
✗ Branch 1 not taken.
12679 if(ret)
18397 return ret;
18398 12679 }
18399
18400
2/2
✓ Branch 0 taken 7621 times.
✓ Branch 1 taken 4995 times.
12616 if(s_version < 52)
18401 {
18402
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7621 times.
7621 if(!temp_combo.triggers.empty())
18403 7621 temp_combo.only_gentrig = (temp_combo.triggers[0].triggerflags[0] & combotriggerONLYGENTRIG) ? 1 : 0;
18404 7621 }
18405
1/2
✓ Branch 0 taken 4995 times.
✗ Branch 1 not taken.
4995 else if(!p_getc(&temp_combo.only_gentrig,f))
18406 return qe_invalid;
18407 12616 }
18408
2/2
✓ Branch 0 taken 349853 times.
✓ Branch 1 taken 805765 times.
1155618 if(combo_has_flags&CHAS_LIFT)
18409 {
18410
1/2
✓ Branch 0 taken 805765 times.
✗ Branch 1 not taken.
805765 if(!p_igetw(&temp_combo.liftcmb,f))
18411 return qe_invalid;
18412
1/2
✓ Branch 0 taken 805765 times.
✗ Branch 1 not taken.
805765 if(!p_getc(&temp_combo.liftcs,f))
18413 return qe_invalid;
18414
1/2
✓ Branch 0 taken 805765 times.
✗ Branch 1 not taken.
805765 if(!p_igetw(&temp_combo.liftundercmb,f))
18415 return qe_invalid;
18416
1/2
✓ Branch 0 taken 805765 times.
✗ Branch 1 not taken.
805765 if(!p_getc(&temp_combo.liftundercs,f))
18417 return qe_invalid;
18418
1/2
✓ Branch 0 taken 805765 times.
✗ Branch 1 not taken.
805765 if(!p_getc(&temp_combo.liftdmg,f))
18419 return qe_invalid;
18420
1/2
✓ Branch 0 taken 805765 times.
✗ Branch 1 not taken.
805765 if(!p_getc(&temp_combo.liftlvl,f))
18421 return qe_invalid;
18422
1/2
✓ Branch 0 taken 805765 times.
✗ Branch 1 not taken.
805765 if(!p_getc(&temp_combo.liftitm,f))
18423 return qe_invalid;
18424
1/2
✓ Branch 0 taken 805765 times.
✗ Branch 1 not taken.
805765 if(!p_getc(&temp_combo.liftflags,f))
18425 return qe_invalid;
18426
1/2
✓ Branch 0 taken 805765 times.
✗ Branch 1 not taken.
805765 if(!p_getc(&temp_combo.liftgfx,f))
18427 return qe_invalid;
18428
1/2
✓ Branch 0 taken 805765 times.
✗ Branch 1 not taken.
805765 if(!p_getc(&temp_combo.liftsprite,f))
18429 return qe_invalid;
18430
1/2
✓ Branch 0 taken 805765 times.
✗ Branch 1 not taken.
805765 if(!p_getc(&temp_combo.liftsfx,f))
18431 return qe_invalid;
18432
1/2
✓ Branch 0 taken 805765 times.
✗ Branch 1 not taken.
805765 if(!p_igetw(&temp_combo.liftbreaksprite,f))
18433 return qe_invalid;
18434
1/2
✓ Branch 0 taken 805765 times.
✗ Branch 1 not taken.
805765 if(!p_getc(&temp_combo.liftbreaksfx,f))
18435 return qe_invalid;
18436
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 805765 times.
805765 if(s_version >= 34)
18437 {
18438
1/2
✓ Branch 0 taken 805765 times.
✗ Branch 1 not taken.
805765 if(!p_getc(&temp_combo.lifthei,f))
18439 return qe_invalid;
18440
1/2
✓ Branch 0 taken 805765 times.
✗ Branch 1 not taken.
805765 if(!p_getc(&temp_combo.lifttime,f))
18441 return qe_invalid;
18442 805765 }
18443
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 805751 times.
805765 if(s_version >= 39)
18444 {
18445
1/2
✓ Branch 0 taken 805751 times.
✗ Branch 1 not taken.
805751 if(!p_getc(&temp_combo.lift_parent_item,f))
18446 return qe_invalid;
18447 805751 }
18448 805765 auto& weap_data = temp_combo.lift_weap_data;
18449
4/4
✓ Branch 0 taken 805648 times.
✓ Branch 1 taken 117 times.
✓ Branch 2 taken 805620 times.
✓ Branch 3 taken 28 times.
805765 if(s_version >= 51 && s_version < 55)
18450 {
18451
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
28 if(!p_getc(&weap_data.light_rads[WPNSPR_BASE],f))
18452 return qe_invalid;
18453
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
28 if(!p_getc(&weap_data.glow_shape,f))
18454 return qe_invalid;
18455 28 }
18456
18457
2/2
✓ Branch 0 taken 805620 times.
✓ Branch 1 taken 145 times.
805765 if(s_version >= 55)
18458 {
18459
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 805620 times.
805620 if(auto ret = read_weap_data(weap_data, f))
18460 return ret;
18461 805620 }
18462 else
18463 {
18464 145 auto const& pitm = itemsbuf[temp_combo.lift_parent_item];
18465 145 auto weap_glow = weap_data.light_rads[WPNSPR_BASE];
18466
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 139 times.
145 switch(pitm.family)
18467 {
18468 case itype_bomb:
18469 case itype_sbomb:
18470 6 weap_data = pitm.weap_data;
18471
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if(!(weap_data.wflags & WFLAG_UPDATE_IGNITE_SPRITE))
18472 {
18473 6 weap_data.flags |= wdata_glow_rad;
18474 6 weap_data.light_rads[WPNSPR_BASE] = weap_glow;
18475 6 }
18476 6 break;
18477 default:
18478 139 weap_data.wflags |= WFLAG_BREAK_WHEN_LANDING;
18479 139 weap_data.flags |= wdata_glow_rad;
18480 139 }
18481 145 weap_data.moveflags |= move_obeys_grav|move_can_pitfall;
18482
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 81 times.
145 if(temp_combo.liftflags & LF_BREAKONSOLID)
18483 64 weap_data.wflags |= WFLAG_BREAK_ON_SOLID;
18484 }
18485 805765 }
18486
18487
2/2
✓ Branch 0 taken 1122954 times.
✓ Branch 1 taken 32664 times.
1155618 if(combo_has_flags&CHAS_GENERAL)
18488 {
18489
1/2
✓ Branch 0 taken 32664 times.
✗ Branch 1 not taken.
32664 if(!p_getc(&temp_combo.speed_mult,f))
18490 return qe_invalid;
18491
1/2
✓ Branch 0 taken 32664 times.
✗ Branch 1 not taken.
32664 if(!p_getc(&temp_combo.speed_div,f))
18492 return qe_invalid;
18493
1/2
✓ Branch 0 taken 32664 times.
✗ Branch 1 not taken.
32664 if(!p_igetzf(&temp_combo.speed_add,f))
18494 return qe_invalid;
18495
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32664 times.
32664 if(s_version >= 42)
18496 {
18497
1/2
✓ Branch 0 taken 32664 times.
✗ Branch 1 not taken.
32664 if(!p_getc(&temp_combo.sfx_appear,f))
18498 return qe_invalid;
18499
1/2
✓ Branch 0 taken 32664 times.
✗ Branch 1 not taken.
32664 if(!p_getc(&temp_combo.sfx_disappear,f))
18500 return qe_invalid;
18501
1/2
✓ Branch 0 taken 32664 times.
✗ Branch 1 not taken.
32664 if(!p_getc(&temp_combo.sfx_loop,f))
18502 return qe_invalid;
18503
1/2
✓ Branch 0 taken 32664 times.
✗ Branch 1 not taken.
32664 if(!p_getc(&temp_combo.sfx_walking,f))
18504 return qe_invalid;
18505
1/2
✓ Branch 0 taken 32664 times.
✗ Branch 1 not taken.
32664 if(!p_getc(&temp_combo.sfx_standing,f))
18506 return qe_invalid;
18507
1/2
✓ Branch 0 taken 32664 times.
✗ Branch 1 not taken.
32664 if(!p_getc(&temp_combo.spr_appear,f))
18508 return qe_invalid;
18509
1/2
✓ Branch 0 taken 32664 times.
✗ Branch 1 not taken.
32664 if(!p_getc(&temp_combo.spr_disappear,f))
18510 return qe_invalid;
18511
1/2
✓ Branch 0 taken 32664 times.
✗ Branch 1 not taken.
32664 if(!p_getc(&temp_combo.spr_walking,f))
18512 return qe_invalid;
18513
1/2
✓ Branch 0 taken 32664 times.
✗ Branch 1 not taken.
32664 if(!p_getc(&temp_combo.spr_standing,f))
18514 return qe_invalid;
18515 32664 }
18516
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32664 times.
32664 if(s_version >= 44)
18517 {
18518
1/2
✓ Branch 0 taken 32664 times.
✗ Branch 1 not taken.
32664 if(!p_getc(&temp_combo.sfx_tap,f))
18519 return qe_invalid;
18520 32664 }
18521
2/2
✓ Branch 0 taken 366 times.
✓ Branch 1 taken 32298 times.
32664 if(s_version >= 49)
18522 {
18523
1/2
✓ Branch 0 taken 32298 times.
✗ Branch 1 not taken.
32298 if(!p_getc(&temp_combo.sfx_landing,f))
18524 return qe_invalid;
18525 32298 }
18526
2/2
✓ Branch 0 taken 366 times.
✓ Branch 1 taken 32298 times.
32664 if(s_version >= 50)
18527 {
18528
1/2
✓ Branch 0 taken 32298 times.
✗ Branch 1 not taken.
32298 if(!p_getc(&temp_combo.spr_falling,f))
18529 return qe_invalid;
18530
1/2
✓ Branch 0 taken 32298 times.
✗ Branch 1 not taken.
32298 if(!p_getc(&temp_combo.spr_drowning,f))
18531 return qe_invalid;
18532
1/2
✓ Branch 0 taken 32298 times.
✗ Branch 1 not taken.
32298 if(!p_getc(&temp_combo.spr_lava_drowning,f))
18533 return qe_invalid;
18534
1/2
✓ Branch 0 taken 32298 times.
✗ Branch 1 not taken.
32298 if(!p_getc(&temp_combo.sfx_falling,f))
18535 return qe_invalid;
18536
1/2
✓ Branch 0 taken 32298 times.
✗ Branch 1 not taken.
32298 if(!p_getc(&temp_combo.sfx_drowning,f))
18537 return qe_invalid;
18538
1/2
✓ Branch 0 taken 32298 times.
✗ Branch 1 not taken.
32298 if(!p_getc(&temp_combo.sfx_lava_drowning,f))
18539 return qe_invalid;
18540 32298 }
18541
2/2
✓ Branch 0 taken 17403 times.
✓ Branch 1 taken 15261 times.
32664 if(s_version >= 56)
18542 {
18543
1/2
✓ Branch 0 taken 15261 times.
✗ Branch 1 not taken.
15261 if(!p_igetzf(&temp_combo.z_height,f))
18544 return qe_invalid;
18545
1/2
✓ Branch 0 taken 15261 times.
✗ Branch 1 not taken.
15261 if(!p_igetzf(&temp_combo.z_step_height,f))
18546 return qe_invalid;
18547 15261 }
18548 32664 }
18549
1/2
✓ Branch 0 taken 1155618 times.
✗ Branch 1 not taken.
1155618 if(combo_has_flags&CHAS_MISC_WEAP_DATA)
18550 {
18551 if(auto ret = read_weap_data(temp_combo.misc_weap_data, f))
18552 return ret;
18553 }
18554 1155618 }
18555 1464929 update_combo(temp_combo, s_version);
18556 1464929 return 0;
18557 1464929 }
18558
18559 481 int32_t readcombos(PACKFILE *f, zquestheader *Header, word version, word build, word start_combo, word max_combos)
18560 {
18561
2/2
✓ Branch 0 taken 457 times.
✓ Branch 1 taken 24 times.
481 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_combos);
18562
18563 481 word section_version=0;
18564 481 word combos_used=0;
18565 int32_t dummy;
18566 byte padding;
18567 481 newcombo temp_combo;
18568
18569
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 480 times.
481 if (!should_skip)
18570 {
18571
1/2
✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
480 reset_all_combo_animations();
18572
1/2
✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
480 init_combo_classes();
18573
18574
2/2
✓ Branch 0 taken 31334400 times.
✓ Branch 1 taken 480 times.
31334880 for(int32_t q = start_combo; q < start_combo+max_combos; ++q)
18575
1/2
✓ Branch 0 taken 31334400 times.
✗ Branch 1 not taken.
31334400 combobuf[q].clear();
18576 480 }
18577
18578
2/2
✓ Branch 0 taken 457 times.
✓ Branch 1 taken 24 times.
481 if(version > 0x192) //Version info
18579 {
18580
2/4
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 457 times.
✗ Branch 3 not taken.
457 if(!p_igetw(&section_version,f))
18581 {
18582 return qe_invalid;
18583 }
18584 457 FFCore.quest_format[vCombos] = section_version;
18585
2/4
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 457 times.
✗ Branch 3 not taken.
457 if(!read_deprecated_section_cversion(f))
18586 {
18587 return qe_invalid;
18588 }
18589
18590 //section size
18591
2/4
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 457 times.
✗ Branch 3 not taken.
457 if(!p_igetl(&dummy,f))
18592 {
18593 return qe_invalid;
18594 }
18595 457 }
18596
18597
2/2
✓ Branch 0 taken 187 times.
✓ Branch 1 taken 294 times.
481 if(section_version > 32) //Cleanup time!
18598 {
18599
2/4
✓ Branch 0 taken 187 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 187 times.
✗ Branch 3 not taken.
187 if(!p_igetw(&combos_used,f))
18600 {
18601 return qe_invalid;
18602 }
18603
2/2
✓ Branch 0 taken 1464929 times.
✓ Branch 1 taken 187 times.
1465116 for(int32_t i=0; i<combos_used; i++)
18604 {
18605
1/2
✓ Branch 0 taken 1464929 times.
✗ Branch 1 not taken.
1464929 auto ret = readcombo_loop(f,section_version,temp_combo);
18606
1/2
✓ Branch 0 taken 1464929 times.
✗ Branch 1 not taken.
1464929 if(ret) return ret;
18607
1/2
✓ Branch 0 taken 1464929 times.
✗ Branch 1 not taken.
1464929 if(i>=start_combo)
18608 {
18609
1/2
✓ Branch 0 taken 1464929 times.
✗ Branch 1 not taken.
1464929 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
18610 {
18611 temp_combo.script = 0;
18612 for(int q = 0; q < 8; ++q)
18613 temp_combo.initd[q] = 0;
18614 }
18615
1/2
✓ Branch 0 taken 1464929 times.
✗ Branch 1 not taken.
1464929 combobuf[i] = temp_combo;
18616 1464929 }
18617 1464929 }
18618 187 }
18619 else //Call the old function for all old versions
18620 {
18621
1/2
✓ Branch 0 taken 294 times.
✗ Branch 1 not taken.
294 auto ret = readcombos_old(section_version,f,Header,version,build,start_combo,max_combos);
18622
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 294 times.
294 if(ret) return ret; //error, end read
18623 }
18624
18625
2/2
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 1 times.
481 if (should_skip)
18626 1 return 0;
18627
18628
2/2
✓ Branch 0 taken 302 times.
✓ Branch 1 taken 178 times.
480 if(!get_qr(qr_ALLOW_EDITING_COMBO_0))
18629 {
18630 178 combobuf[0].walk = 0xF0;
18631 178 combobuf[0].type = 0;
18632 178 combobuf[0].flag = 0;
18633 178 }
18634
18635
1/2
✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
480 setup_combo_animations();
18636
1/2
✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
480 setup_combo_animations2();
18637 480 return 0;
18638 481 }
18639
18640 398 int32_t readcomboaliases(PACKFILE *f, zquestheader *Header, word version, word build)
18641 {
18642 //these are here to bypass compiler warnings about unused arguments
18643 398 Header=Header;
18644 398 version=version;
18645 398 build=build;
18646
18647 int32_t dummy;
18648 398 word sversion=0, c_sversion;
18649
18650 //section version info
18651
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 if(!p_igetw(&sversion,f))
18652 {
18653 return qe_invalid;
18654 }
18655
18656 398 FFCore.quest_format[vComboAliases] = sversion;
18657
18658
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_igetw(&c_sversion,f))
18659 {
18660 return qe_invalid;
18661 }
18662
18663 //section size
18664
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_igetl(&dummy,f))
18665 {
18666 return qe_invalid;
18667 }
18668
18669 398 int32_t max_num_combo_aliases = MAXCOMBOALIASES;
18670
18671
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 206 times.
398 if(sversion < 3) // max saved combo alias' upped from 256 to 2048.
18672 {
18673 206 max_num_combo_aliases = MAX250COMBOALIASES;
18674 206 }
18675
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(sversion < 2) // max saved combo alias' upped from 256 to 2048.
18676 {
18677 max_num_combo_aliases = OLDMAXCOMBOALIASES;
18678 }
18679
18680
2/2
✓ Branch 0 taken 1994752 times.
✓ Branch 1 taken 398 times.
1995150 for(int32_t j=0; j<max_num_combo_aliases; j++)
18681 {
18682 byte width,height,mask,tempcset;
18683 int32_t count;
18684 word tempword;
18685 byte tempbyte;
18686
18687
1/2
✓ Branch 0 taken 1994752 times.
✗ Branch 1 not taken.
1994752 if(!p_igetw(&tempword,f))
18688 {
18689 return qe_invalid;
18690 }
18691
18692 1994752 combo_aliases[j].combo = tempword;
18693
18694
1/2
✓ Branch 0 taken 1994752 times.
✗ Branch 1 not taken.
1994752 if(!p_getc(&tempbyte,f))
18695 {
18696 return qe_invalid;
18697 }
18698
18699 1994752 combo_aliases[j].cset = tempbyte;
18700
18701
1/2
✓ Branch 0 taken 1994752 times.
✗ Branch 1 not taken.
1994752 if(!p_getc(&width,f))
18702 {
18703 return qe_invalid;
18704 }
18705
18706
1/2
✓ Branch 0 taken 1994752 times.
✗ Branch 1 not taken.
1994752 if(!p_getc(&height,f))
18707 {
18708 return qe_invalid;
18709 }
18710
18711
1/2
✓ Branch 0 taken 1994752 times.
✗ Branch 1 not taken.
1994752 if(!p_getc(&mask,f))
18712 {
18713 return qe_invalid;
18714 }
18715
18716 1994752 count=(width+1)*(height+1)*(comboa_lmasktotal(mask)+1);
18717
18718 1994752 combo_aliases[j].width = width;
18719 1994752 combo_aliases[j].height = height;
18720 1994752 combo_aliases[j].layermask = mask;
18721 1994752 combo_aliases[j].combos.clear();
18722 1994752 combo_aliases[j].csets.clear();
18723
18724
2/2
✓ Branch 0 taken 2047610 times.
✓ Branch 1 taken 1994752 times.
4042362 for(int32_t k=0; k<count; k++)
18725 {
18726
1/2
✓ Branch 0 taken 2047610 times.
✗ Branch 1 not taken.
2047610 if(!p_igetw(&tempword,f))
18727 {
18728 return qe_invalid;
18729 }
18730
18731 2047610 combo_aliases[j].combos[k] = tempword;
18732 2047610 }
18733
18734
2/2
✓ Branch 0 taken 2047610 times.
✓ Branch 1 taken 1994752 times.
4042362 for(int32_t k=0; k<count; k++)
18735 {
18736
1/2
✓ Branch 0 taken 2047610 times.
✗ Branch 1 not taken.
2047610 if(!p_getc(&tempcset,f))
18737 {
18738 return qe_invalid;
18739 }
18740
18741 2047610 combo_aliases[j].csets[k] = tempcset;
18742 2047610 }
18743 1994752 }
18744
18745 //Combo pools!
18746 398 word num_combo_pools = 0;
18747
2/2
✓ Branch 0 taken 211 times.
✓ Branch 1 taken 187 times.
398 if(sversion >= 4)
18748 {
18749
1/2
✓ Branch 0 taken 187 times.
✗ Branch 1 not taken.
187 if(!p_igetw(&num_combo_pools,f))
18750 {
18751 return qe_invalid;
18752 }
18753 187 }
18754
18755
2/2
✓ Branch 0 taken 3260416 times.
✓ Branch 1 taken 398 times.
3260814 for(combo_pool& pool : combo_pools)
18756 {
18757 3260416 pool.clear();
18758 }
18759
18760 398 combo_pool temp_cpool;
18761
2/2
✓ Branch 0 taken 472 times.
✓ Branch 1 taken 398 times.
870 for(word cp = 0; cp < num_combo_pools; ++cp)
18762 {
18763 472 int32_t num_combos_in_pool = 0;
18764
2/4
✓ Branch 0 taken 472 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 472 times.
✗ Branch 3 not taken.
472 if(!p_igetl(&num_combos_in_pool,f))
18765 {
18766 return qe_invalid;
18767 }
18768
2/2
✓ Branch 0 taken 376 times.
✓ Branch 1 taken 96 times.
472 if(num_combos_in_pool < 1) continue; //nothing to read
18769
18770
1/2
✓ Branch 0 taken 376 times.
✗ Branch 1 not taken.
376 temp_cpool.clear();
18771
18772 int32_t cp_cid; int8_t cp_cs; word cp_quant;
18773
2/2
✓ Branch 0 taken 376 times.
✓ Branch 1 taken 1697 times.
2073 for(auto q = 0; q < num_combos_in_pool; ++q)
18774 {
18775
2/4
✓ Branch 0 taken 1697 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1697 times.
✗ Branch 3 not taken.
1697 if(!p_igetl(&cp_cid,f))
18776 {
18777 return qe_invalid;
18778 }
18779
2/4
✓ Branch 0 taken 1697 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1697 times.
✗ Branch 3 not taken.
1697 if(!p_getc(&cp_cs,f))
18780 {
18781 return qe_invalid;
18782 }
18783
2/4
✓ Branch 0 taken 1697 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1697 times.
✗ Branch 3 not taken.
1697 if(!p_igetw(&cp_quant,f))
18784 {
18785 return qe_invalid;
18786 }
18787
1/2
✓ Branch 0 taken 1697 times.
✗ Branch 1 not taken.
1697 temp_cpool.add(cp_cid, cp_cs, cp_quant);
18788 1697 }
18789
18790
1/2
✓ Branch 0 taken 376 times.
✗ Branch 1 not taken.
376 combo_pools[cp] = temp_cpool;
18791 376 }
18792
18793 //Autocombos!
18794 398 word num_combo_autos = 0;
18795
2/2
✓ Branch 0 taken 175 times.
✓ Branch 1 taken 223 times.
398 if (sversion >= 5)
18796 {
18797
2/4
✓ Branch 0 taken 175 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 175 times.
✗ Branch 3 not taken.
175 if (!p_igetw(&num_combo_autos, f))
18798 {
18799 return qe_invalid;
18800 }
18801 175 }
18802
18803
2/2
✓ Branch 0 taken 398 times.
✓ Branch 1 taken 3260416 times.
3260814 for (combo_auto& cauto : combo_autos)
18804 {
18805
1/2
✓ Branch 0 taken 3260416 times.
✗ Branch 1 not taken.
3260416 cauto.clear(true);
18806 }
18807
18808
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 combo_auto temp_cauto;
18809
2/2
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 398 times.
524 for (word ca = 0; ca < num_combo_autos; ++ca)
18810 {
18811 byte type;
18812 int32_t display_cid, erase_cid;
18813 byte flags, arg;
18814
2/4
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
126 if (!p_getc(&type, f))
18815 {
18816 return qe_invalid;
18817 }
18818
2/4
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
126 if (!p_igetl(&display_cid, f))
18819 {
18820 return qe_invalid;
18821 }
18822
2/4
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
126 if (!p_igetl(&erase_cid, f))
18823 {
18824 return qe_invalid;
18825 }
18826
2/4
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
126 if (!p_getc(&flags, f))
18827 {
18828 return qe_invalid;
18829 }
18830
2/4
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
126 if (!p_getc(&arg, f))
18831 {
18832 return qe_invalid;
18833 }
18834 126 int32_t num_combos_in_cauto = 0;
18835
2/4
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
126 if (!p_igetl(&num_combos_in_cauto, f))
18836 {
18837 return qe_invalid;
18838 }
18839
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 21 times.
126 if (num_combos_in_cauto < 1) continue; //nothing to read
18840
18841
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 temp_cauto.clear();
18842
18843
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 temp_cauto.setType(type);
18844
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 temp_cauto.setDisplay(display_cid);
18845
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 temp_cauto.setEraseCombo(erase_cid);
18846
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 temp_cauto.setFlags(flags);
18847
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 temp_cauto.setArg(arg);
18848
18849 int32_t ca_cid; byte ca_ctype; int16_t ca_offset; int16_t ca_engrave_offset;
18850
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 2361 times.
2466 for (auto q = 0; q < num_combos_in_cauto; ++q)
18851 {
18852
2/4
✓ Branch 0 taken 2361 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2361 times.
✗ Branch 3 not taken.
2361 if (!p_getc(&ca_ctype, f))
18853 {
18854 return qe_invalid;
18855 }
18856
2/4
✓ Branch 0 taken 2361 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2361 times.
✗ Branch 3 not taken.
2361 if (!p_igetl(&ca_cid, f))
18857 {
18858 return qe_invalid;
18859 }
18860
1/2
✓ Branch 0 taken 2361 times.
✗ Branch 1 not taken.
2361 temp_cauto.addEntry(ca_cid, ca_ctype, q, -1);
18861 2361 }
18862
18863
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 combo_autos[ca] = temp_cauto;
18864 105 }
18865
18866 398 return 0;
18867 398 }
18868
18869 804 int32_t readcolordata(PACKFILE *f, miscQdata *Misc, word version, word build, word start_cset, word max_csets)
18870 {
18871
2/2
✓ Branch 0 taken 780 times.
✓ Branch 1 taken 24 times.
804 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_colors);
18872
18873 //these are here to bypass compiler warnings about unused arguments
18874 //THE *48 REFERS TO EACH CSET BEING 16 COLORS with 3 VALUES OF RGB (3*16 is 48)
18875 //Capitalized cause it'll save you a headache. -Deedee
18876 804 start_cset=start_cset;
18877 804 max_csets=max_csets;
18878 804 word s_version=0;
18879
18880 miscQdata temp_misc;
18881 804 memcpy(&temp_misc, Misc, sizeof(temp_misc));
18882
18883 byte temp_colordata[48];
18884 char temp_palname[PALNAMESIZE+1];
18885
18886 int32_t dummy;
18887 word palcycles;
18888
18889
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 780 times.
804 if(version > 0x192)
18890 {
18891 //section version info
18892
1/2
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
780 if(!p_igetw(&s_version,f))
18893 {
18894 return qe_invalid;
18895 }
18896
18897 780 FFCore.quest_format[vCSets] = s_version;
18898
18899
1/2
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
780 if(!p_igetw(&dummy,f))
18900 {
18901 return qe_invalid;
18902 }
18903
18904 //section size
18905
1/2
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
780 if(!p_igetl(&dummy,f))
18906 {
18907 return qe_invalid;
18908 }
18909 780 }
18910
2/2
✓ Branch 0 taken 612 times.
✓ Branch 1 taken 192 times.
804 if (s_version < 5)
18911 {
18912
4/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 594 times.
✓ Branch 2 taken 588 times.
✓ Branch 3 taken 6 times.
612 bool RealOldVerion = ((version < 0x192)||((version == 0x192)&&(build<73)));
18913
18914 //finally... section data
18915 612 int32_t q = 0;
18916 612 int32_t p = -15;
18917
2/2
✓ Branch 0 taken 146880 times.
✓ Branch 1 taken 612 times.
147492 for(int32_t i=0; i<oldpdTOTAL; ++i)
18918 {
18919 146880 memset(temp_colordata, 0, 48);
18920
18921
1/2
✓ Branch 0 taken 146880 times.
✗ Branch 1 not taken.
146880 if(!pfread(temp_colordata,48,f))
18922 {
18923 return qe_invalid;
18924 }
18925
18926
2/2
✓ Branch 0 taken 240 times.
✓ Branch 1 taken 146640 times.
146880 if (should_skip)
18927 240 continue;
18928
18929 146640 memcpy(&colordata[q*48], temp_colordata, 48);
18930
18931 146640 ++q;
18932
8/8
✓ Branch 0 taken 136864 times.
✓ Branch 1 taken 9776 times.
✓ Branch 2 taken 10387 times.
✓ Branch 3 taken 126477 times.
✓ Branch 4 taken 1222 times.
✓ Branch 5 taken 9165 times.
✓ Branch 6 taken 36 times.
✓ Branch 7 taken 1186 times.
146640 if (p > 0 && (p%13)==12 && (i < oldpoSPRITE || !RealOldVerion)) //It's > 0 instead of >= 0 because it should append
18933 {
18934
1/2
✓ Branch 0 taken 10351 times.
✗ Branch 1 not taken.
10351 if (s_version < 5) //Bumping up the size of level palettes
18935 {
18936 10351 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
18937 10351 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
18938 10351 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
18939 10351 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
18940 10351 q+=4;
18941 10351 }
18942 else
18943 {
18944 for(int m = 0; m < 4; ++m)
18945 {
18946 memset(temp_colordata, 0, 48);
18947 if(!pfread(temp_colordata,48,f))
18948 {
18949 return qe_invalid;
18950 }
18951 memcpy(&colordata[q*48], temp_colordata, 48);
18952 ++q;
18953 }
18954 }
18955 10351 }
18956 146640 ++p;
18957 146640 }
18958
18959
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 594 times.
612 if(RealOldVerion)
18960 {
18961
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if (!should_skip)
18962 {
18963 18 memcpy(colordata+(poSPRITE255*48), colordata+((q-30)*48), 30*16*3);
18964 18 memset(colordata+((q-30)*48), 0, ((poSPRITE255-(q-30))*48));
18965 18 memcpy(colordata+((poSPRITE255+11)*48), colordata+((poSPRITE255+10)*48), 48);
18966 18 memcpy(colordata+((poSPRITE255+10)*48), colordata+((poSPRITE255+9)*48), 48);
18967 18 memcpy(colordata+((poSPRITE255+9)*48), colordata+((poSPRITE255+8)*48), 48);
18968 18 memset(colordata+((poSPRITE255+8)*48), 0, 48);
18969 18 }
18970 18 }
18971 else
18972 {
18973 594 memset(temp_colordata, 0, 48);
18974
18975
2/2
✓ Branch 0 taken 1861002 times.
✓ Branch 1 taken 594 times.
1861596 for(int32_t i=0; i<newpdTOTAL-oldpdTOTAL; ++i)
18976 {
18977
1/2
✓ Branch 0 taken 1861002 times.
✗ Branch 1 not taken.
1861002 if(!pfread(temp_colordata,48,f))
18978 {
18979 return qe_invalid;
18980 }
18981
18982
2/2
✓ Branch 0 taken 3133 times.
✓ Branch 1 taken 1857869 times.
1861002 if (should_skip)
18983 3133 continue;
18984
18985 1857869 memcpy(&colordata[q*48], temp_colordata, 48);
18986
18987 1857869 ++q;
18988
7/8
✓ Branch 0 taken 1857869 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 142913 times.
✓ Branch 3 taken 1714956 times.
✓ Branch 4 taken 1186 times.
✓ Branch 5 taken 141727 times.
✓ Branch 6 taken 1058 times.
✓ Branch 7 taken 128 times.
1857869 if (p > 0 && (p%13)==12 && (i < (newpoSPRITE-oldpdTOTAL) || (s_version >= 4))) //It's > 0 instead of >= 0 because it should append
18989 {
18990
1/2
✓ Branch 0 taken 142785 times.
✗ Branch 1 not taken.
142785 if (s_version < 5) //Bumping up the size of level palettes
18991 {
18992 142785 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
18993 142785 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
18994 142785 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
18995 142785 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
18996 142785 q+=4;
18997 142785 }
18998 else
18999 {
19000 for(int m = 0; m < 4; ++m)
19001 {
19002 memset(temp_colordata, 0, 48);
19003 if(!pfread(temp_colordata,48,f))
19004 {
19005 return qe_invalid;
19006 }
19007 memcpy(&colordata[q*48], temp_colordata, 48);
19008 ++q;
19009 }
19010 }
19011 142785 }
19012 1857869 ++p;
19013 1857869 }
19014
19015
2/2
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 529 times.
594 if(s_version < 4)
19016 {
19017
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 64 times.
65 if (!should_skip)
19018 {
19019 64 memcpy(colordata+(poSPRITE255*48), colordata+((q-30)*48), 30*16*3);
19020 64 memset(colordata+((q-30)*48), 0, ((poSPRITE255-(q-30))*48));
19021 64 }
19022 65 }
19023 else
19024 {
19025
2/2
✓ Branch 0 taken 1760512 times.
✓ Branch 1 taken 529 times.
1761041 for(int32_t i=0; i<newerpdTOTAL-newpdTOTAL; ++i)
19026 {
19027
1/2
✓ Branch 0 taken 1760512 times.
✗ Branch 1 not taken.
1760512 if(!pfread(temp_colordata,48,f))
19028 {
19029 return qe_invalid;
19030 }
19031
19032
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1760512 times.
1760512 if (should_skip)
19033 continue;
19034
19035 1760512 memcpy(&colordata[q*48], temp_colordata, 48);
19036 1760512 ++q;
19037
5/6
✓ Branch 0 taken 1760512 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 135424 times.
✓ Branch 3 taken 1625088 times.
✓ Branch 4 taken 1058 times.
✓ Branch 5 taken 134366 times.
1760512 if (p > 0 && (p%13)==12 && i < newerpoSPRITE-newpdTOTAL) //It's > 0 instead of >= 0 because it should append
19038 {
19039
1/2
✓ Branch 0 taken 134366 times.
✗ Branch 1 not taken.
134366 if (s_version < 5) //Bumping up the size of level palettes
19040 {
19041 134366 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
19042 134366 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
19043 134366 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
19044 134366 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
19045 134366 q+=4;
19046 134366 }
19047 else
19048 {
19049 for(int m = 0; m < 4; ++m)
19050 {
19051 memset(temp_colordata, 0, 48);
19052 if(!pfread(temp_colordata,48,f))
19053 {
19054 return qe_invalid;
19055 }
19056 memcpy(&colordata[q*48], temp_colordata, 48);
19057 ++q;
19058 }
19059 }
19060 134366 }
19061 1760512 ++p;
19062 1760512 }
19063
19064 //By this point, q should be about equal to pdTOTAL255. If it isn't, I've fucked up. -Deedee
19065 }
19066 }
19067 612 }
19068 else
19069 {
19070
2/2
✓ Branch 0 taken 1679808 times.
✓ Branch 1 taken 192 times.
1680000 for(int32_t i=0; i<pdTOTAL255; ++i)
19071 {
19072 1679808 memset(temp_colordata, 0, 48);
19073
19074
1/2
✓ Branch 0 taken 1679808 times.
✗ Branch 1 not taken.
1679808 if(!pfread(temp_colordata,48,f))
19075 {
19076 return qe_invalid;
19077 }
19078
19079 1679808 memcpy(&colordata[i*48], temp_colordata, 48);
19080 1679808 }
19081 }
19082
19083
4/4
✓ Branch 0 taken 803 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 147 times.
✓ Branch 3 taken 656 times.
804 if (!should_skip && s_version < 6)
19084 {
19085
2/2
✓ Branch 0 taken 275488512 times.
✓ Branch 1 taken 656 times.
275489168 for (int i = 0; i < psTOTAL255; i++)
19086 {
19087 275488512 colordata[i] = _rgb_scale_6[colordata[i]];
19088 275488512 }
19089 656 }
19090
19091
5/6
✓ Branch 0 taken 786 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 780 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
804 if((version < 0x192)||((version == 0x192)&&(build<76)))
19092 {
19093
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if (!should_skip)
19094 18 init_palnames();
19095 18 }
19096 else
19097 {
19098 786 int32_t palnamestoread = 0;
19099
19100
2/2
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 721 times.
786 if(s_version < 3)
19101 65 palnamestoread = OLDMAXLEVELS;
19102 else
19103 721 palnamestoread = 512;
19104
19105
2/2
✓ Branch 0 taken 385792 times.
✓ Branch 1 taken 786 times.
386578 for(int32_t i=0; i<palnamestoread; ++i)
19106 {
19107
1/2
✓ Branch 0 taken 385792 times.
✗ Branch 1 not taken.
385792 if(!p_getstr(temp_palname,PALNAMESIZE,f))
19108 {
19109 return qe_invalid;
19110 }
19111
19112
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 385536 times.
385792 if (!should_skip)
19113 385536 memcpy(palnames[i], temp_palname, PALNAMESIZE);
19114 385792 }
19115
19116
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 785 times.
786 if (should_skip)
19117 1 return 0;
19118
19119
2/2
✓ Branch 0 taken 16384 times.
✓ Branch 1 taken 785 times.
17169 for(int32_t i=palnamestoread; i<MAXLEVELS; i++)
19120 {
19121 16384 memset(palnames[i], 0, PALNAMESIZE);
19122 16384 }
19123 }
19124
19125
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 780 times.
803 if(version > 0x192)
19126 {
19127
2/2
✓ Branch 0 taken 199680 times.
✓ Branch 1 taken 780 times.
200460 for(int32_t i=0; i<256; i++)
19128 {
19129
2/2
✓ Branch 0 taken 599040 times.
✓ Branch 1 taken 199680 times.
798720 for(int32_t j=0; j<3; j++)
19130 {
19131 599040 temp_misc.cycles[i][j].first=0;
19132 599040 temp_misc.cycles[i][j].count=0;
19133 599040 temp_misc.cycles[i][j].speed=0;
19134 599040 }
19135 199680 }
19136
19137
1/2
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
780 if(!p_igetw(&palcycles,f))
19138 {
19139 return qe_invalid;
19140 }
19141
19142
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 780 times.
780 if (palcycles > NUM_PAL_CYCLES)
19143 {
19144 return qe_invalid;
19145 }
19146
19147
2/2
✓ Branch 0 taken 22341 times.
✓ Branch 1 taken 780 times.
23121 for(int32_t i=0; i<palcycles; i++)
19148 {
19149
2/2
✓ Branch 0 taken 67023 times.
✓ Branch 1 taken 22341 times.
89364 for(int32_t j=0; j<3; j++)
19150 {
19151
1/2
✓ Branch 0 taken 67023 times.
✗ Branch 1 not taken.
67023 if(!p_getc(&temp_misc.cycles[i][j].first,f))
19152 {
19153 return qe_invalid;
19154 }
19155 67023 }
19156
19157
2/2
✓ Branch 0 taken 67023 times.
✓ Branch 1 taken 22341 times.
89364 for(int32_t j=0; j<3; j++)
19158 {
19159
1/2
✓ Branch 0 taken 67023 times.
✗ Branch 1 not taken.
67023 if(!p_getc(&temp_misc.cycles[i][j].count,f))
19160 {
19161 return qe_invalid;
19162 }
19163 67023 }
19164
19165
2/2
✓ Branch 0 taken 67023 times.
✓ Branch 1 taken 22341 times.
89364 for(int32_t j=0; j<3; j++)
19166 {
19167
1/2
✓ Branch 0 taken 67023 times.
✗ Branch 1 not taken.
67023 if(!p_getc(&temp_misc.cycles[i][j].speed,f))
19168 {
19169 return qe_invalid;
19170 }
19171 67023 }
19172 22341 }
19173
19174 780 memcpy(Misc, &temp_misc, sizeof(temp_misc));
19175 780 }
19176
19177 803 return 0;
19178 804 }
19179
19180 804 int32_t readtiles(PACKFILE *f, tiledata *buf, zquestheader *Header, word version, word build, word start_tile, int32_t max_tiles, bool from_init)
19181 {
19182
2/2
✓ Branch 0 taken 780 times.
✓ Branch 1 taken 24 times.
804 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_tiles);
19183
19184 804 int32_t tiles_used=0;
19185 804 word section_version = 0;
19186 804 int32_t section_size= 0;
19187 804 byte *temp_tile = new byte[tilesize(tf32Bit)];
19188
19189 //Tile Expansion
19190 //if ( version >= 0x254 && build >= 41 )
19191
4/4
✓ Branch 0 taken 612 times.
✓ Branch 1 taken 192 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 606 times.
804 if (version < 0x254 && build < 41)
19192 {
19193 606 max_tiles = ZC250MAXTILES;
19194 606 }
19195
19196
19197
2/6
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 804 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
804 if(Header!=NULL&&(!Header->data_flags[ZQ_TILES]&&!from_init)) //keep for old quests
19198 {
19199 if(!init_tiles_for_190(true, Header))
19200 {
19201 al_trace("Unable to initialize tiles\n");
19202 }
19203
19204 delete[] temp_tile;
19205 temp_tile=NULL;
19206 return 0;
19207 }
19208 else
19209 {
19210
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 780 times.
804 if(version > 0x192)
19211 {
19212 //section version info
19213
1/2
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
780 if(!p_igetw(&section_version,f))
19214 {
19215 delete[] temp_tile;
19216 return qe_invalid;
19217 }
19218
19219 780 FFCore.quest_format[vTiles] = section_version;
19220
19221
1/2
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
780 if(!read_deprecated_section_cversion(f))
19222 {
19223 delete[] temp_tile;
19224 return qe_invalid;
19225 }
19226
19227 //section size
19228
1/2
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
780 if(!p_igetl(&section_size,f))
19229 {
19230 delete[] temp_tile;
19231 return qe_invalid;
19232 }
19233 780 }
19234
19235 //if ( build < 41 )
19236 //{
19237 // tiles_used = ZC250MAXTILES;
19238 //}
19239
19240
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 804 times.
804 if(version < 0x174)
19241 {
19242 tiles_used=TILES_PER_PAGE*4;
19243 } //no expanded tile space
19244
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 786 times.
804 else if(version < 0x191)
19245 {
19246 18 tiles_used=OLDMAXTILES;
19247 18 }
19248 else
19249 {
19250 //finally... section data
19251
3/4
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 594 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 192 times.
786 if ( version >= 0x254 && build >= 41 ) //read and write the size of tiles_used properly
19252 {
19253
1/2
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
192 if(!p_igetl(&tiles_used,f))
19254 {
19255 delete[] temp_tile;
19256 return qe_invalid;
19257 }
19258 192 }
19259 else
19260 {
19261
1/2
✓ Branch 0 taken 594 times.
✗ Branch 1 not taken.
594 if(!p_igetw(&tiles_used,f))
19262 {
19263 delete[] temp_tile;
19264 return qe_invalid;
19265 }
19266 }
19267 }
19268
19269
1/2
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
804 tiles_used=zc_min(tiles_used, max_tiles);
19270
19271 //if ( version < 0x254 || ( version >= 0x254 && build < 41 )) //don't do this, it crashes ZQuest. -Z
19272 //if ( version < 0x254 && build < 41 )
19273
3/6
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 192 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
804 if ( version < 0x254 || (version == 0x254 && build < 41) )
19274 //if ( build < 41 )
19275 {
19276
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 tiles_used=zc_min(tiles_used, ZC250MAXTILES-start_tile);
19277 612 }
19278 else //2.55
19279 {
19280
1/2
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
192 tiles_used = zc_min(tiles_used,NEWMAXTILES-start_tile);
19281 }
19282
19283 //if ( section_version > 1 ) tiles_used = NEWMAXTILES;
19284
19285
19286
2/2
✓ Branch 0 taken 18536254 times.
✓ Branch 1 taken 804 times.
18537058 for(int32_t i=0; i<tiles_used; ++i)
19287 {
19288 18536254 byte format=tf4Bit;
19289 18536254 memset(temp_tile, 0, tilesize(tf32Bit));
19290
19291
3/6
✓ Branch 0 taken 2985456 times.
✓ Branch 1 taken 15550798 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2985456 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
18536254 if((version>0x211)||((version==0x211)&&(build>4)))
19292 {
19293
1/2
✓ Branch 0 taken 15550798 times.
✗ Branch 1 not taken.
15550798 if(!p_getc(&format,f))
19294 {
19295 delete[] temp_tile;
19296 return qe_invalid;
19297 }
19298 15550798 }
19299
4/4
✓ Branch 0 taken 7328620 times.
✓ Branch 1 taken 11207634 times.
✓ Branch 2 taken 3354934 times.
✓ Branch 3 taken 3973686 times.
18536254 if(section_version > 2 && !format)
19300 {
19301 3973686 reset_tile(buf,start_tile+i,tf4Bit);
19302 3973686 continue;
19303 }
19304
19305
2/2
✓ Branch 0 taken 14070028 times.
✓ Branch 1 taken 492540 times.
14562568 int size = format == tf4Bit ? 128 : tilesize(format);
19306
1/2
✓ Branch 0 taken 14562568 times.
✗ Branch 1 not taken.
14562568 if(!pfread(temp_tile,size,f))
19307 {
19308 delete[] temp_tile;
19309 return qe_invalid;
19310 }
19311
19312
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14562568 times.
14562568 if (should_skip)
19313 continue;
19314
19315 14562568 buf[start_tile+i].format=format;
19316
19317
2/2
✓ Branch 0 taken 14358683 times.
✓ Branch 1 taken 203885 times.
14562568 if(buf[start_tile+i].data)
19318 {
19319 14358683 free(buf[start_tile+i].data);
19320 14358683 buf[start_tile+i].data=NULL;
19321 14358683 }
19322
19323 14562568 buf[start_tile+i].data=(byte *)malloc(tilesize(buf[start_tile+i].format));
19324
19325
2/2
✓ Branch 0 taken 14070028 times.
✓ Branch 1 taken 492540 times.
14562568 if (format == tf4Bit)
19326 {
19327 byte temp[256];
19328 14070028 byte *si = temp_tile + 128;
19329 14070028 byte *di = temp + 256;
19330
19331
2/2
✓ Branch 0 taken 1800963584 times.
✓ Branch 1 taken 14070028 times.
1815033612 for(int i=127; i>=0; --i)
19332 {
19333 1800963584 (*(--di)) = (*(--si)) >> 4;
19334 1800963584 (*(--di)) = (*si) & 15;
19335 1800963584 }
19336
19337 14070028 memcpy(buf[start_tile+i].data,temp,256);
19338 14070028 }
19339 else
19340 {
19341 492540 memcpy(buf[start_tile+i].data,temp_tile,tilesize(buf[start_tile+i].format));
19342 }
19343 14562568 }
19344 }
19345
19346
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 804 times.
804 if (should_skip)
19347 return 0;
19348
19349
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 612 times.
804 if ( section_version < 2 ) //write blank tile data --check s_version with this again instead?
19350 {
19351
2/2
✓ Branch 0 taken 91175760 times.
✓ Branch 1 taken 612 times.
91176372 for ( int32_t q = ZC250MAXTILES; q < NEWMAXTILES; ++q )
19352 {
19353
19354 //memcpy(buf[q].data,temp_tile,tilesize(buf[q].format));
19355 91175760 reset_tile(buf,q,tf4Bit);
19356
19357
19358 /*
19359
19360 byte tempbyte;
19361 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19362 {
19363 tempbyte=buf[ZC250MAXTILES-1].data[i];
19364 buf[q].data[i] = tempbyte;
19365 }
19366 //int32_t temp = tempbyte=buf[130].data[i];
19367 //buf[q].data = buf[ZC250MAXTILES-1].data;
19368 */
19369 //reset_tile(buf,q,tf4Bit);
19370 91175760 }
19371
19372 612 }
19373
19374
4/6
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 612 times.
✓ Branch 2 taken 192 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 192 times.
804 if ( version < 0x254 || ( version >= 0x254 && build < 41 ))
19375 {
19376
2/2
✓ Branch 0 taken 30358202 times.
✓ Branch 1 taken 612 times.
30358814 for(int32_t i=start_tile+tiles_used; i<max_tiles; ++i)
19377 {
19378 30358202 reset_tile(buf,i,tf4Bit);
19379 30358202 }
19380 612 }
19381 else
19382 {
19383
2/2
✓ Branch 0 taken 33281664 times.
✓ Branch 1 taken 192 times.
33281856 for(int32_t i=start_tile+tiles_used; i<max_tiles; ++i)
19384 {
19385 33281664 reset_tile(buf,i,tf4Bit);
19386 33281664 }
19387 }
19388
19389
5/6
✓ Branch 0 taken 786 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 780 times.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
804 if((version < 0x192)|| ((version == 0x192)&&(build<186)))
19390 {
19391
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 6 times.
24 if(get_qr(qr_BSZELDA)) //
19392 {
19393 byte tempbyte;
19394 6 int32_t floattile=wpnsbuf[iwSwim].tile;
19395
19396
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 6 times.
1542 for(int32_t i=0; i<tilesize(tf4Bit); i++) //BSZelda tiles are out of order //does this include swim tiles?
19397 {
19398 1536 tempbyte=buf[23].data[i];
19399 1536 buf[23].data[i]=buf[24].data[i];
19400 1536 buf[24].data[i]=buf[25].data[i];
19401 1536 buf[25].data[i]=buf[26].data[i];
19402 1536 buf[26].data[i]=tempbyte;
19403 1536 }
19404 //swim tiles are out of order, too, but nobody cared? -Z
19405
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 6 times.
1542 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19406 {
19407 1536 tempbyte=buf[floattile+11].data[i];
19408 1536 buf[floattile+11].data[i]=buf[floattile+12].data[i];
19409 1536 buf[floattile+12].data[i]=tempbyte;
19410 1536 }
19411 6 }
19412 24 }
19413
19414
3/6
✓ Branch 0 taken 721 times.
✓ Branch 1 taken 83 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 721 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
804 if((version < 0x211)||((version == 0x211)&&(build<7))) //Goriya tiles are out of order
19415 {
19416
2/2
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 22 times.
83 if(!get_qr(qr_NEWENEMYTILES))
19417 {
19418 byte tempbyte;
19419
19420
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 22 times.
5654 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19421 {
19422 5632 tempbyte=buf[130].data[i];
19423 5632 buf[130].data[i]=buf[132].data[i];
19424 5632 buf[132].data[i]=tempbyte;
19425
19426 5632 tempbyte=buf[131].data[i];
19427 5632 buf[131].data[i]=buf[133].data[i];
19428 5632 buf[133].data[i]=tempbyte;
19429 5632 }
19430 22 }
19431 83 }
19432
19433 804 al_trace("Registering blank tiles\n");
19434 804 register_blank_tiles();
19435
19436 //memset(temp_tile, 0, tilesize(tf32Bit));
19437
1/2
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
804 delete[] temp_tile;
19438 804 temp_tile=NULL;
19439 804 return 0;
19440 804 }
19441
19442 480 int32_t readtunes(PACKFILE *f, zquestheader *Header, zctune *tunes /*zcmidi_ *midis*/)
19443 {
19444
2/2
✓ Branch 0 taken 457 times.
✓ Branch 1 taken 23 times.
480 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_midis);
19445
19446 static byte fake_midi_flags[32];
19447
19448
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 480 times.
480 byte *mf=should_skip ? fake_midi_flags : midi_flags;
19449 int32_t dummy;
19450 word dummy2;
19451 // zcmidi_ temp_midi;
19452 int32_t tunes_to_read;
19453 480 int32_t tune_count=0;
19454 480 word section_version=0;
19455 480 zctune temp;
19456
19457
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 457 times.
480 if(Header->zelda_version < 0x193)
19458 {
19459 // mf=Header->data_flags+ZQ_MIDIS2;
19460
5/6
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 1 times.
23 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<178)))
19461 {
19462 22 tunes_to_read=MAXCUSTOMMIDIS192b177;
19463 22 }
19464 else
19465 {
19466 1 tunes_to_read=MAXCUSTOMTUNES;
19467 }
19468 23 }
19469 else
19470 {
19471 //section version info
19472
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 if(!p_igetw(&section_version,f))
19473 {
19474 return qe_invalid;
19475 }
19476
19477
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
457 if (!should_skip)
19478 457 FFCore.quest_format[vMIDIs] = section_version;
19479
19480
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 if(!p_igetw(&dummy2,f))
19481 {
19482 return qe_invalid;
19483 }
19484
19485 //section size
19486
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 if(!p_igetl(&dummy,f))
19487 {
19488 return qe_invalid;
19489 }
19490
19491 //finally... section data
19492
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 if(!pfread(midi_flags,sizeof(midi_flags),f))
19493 {
19494 return qe_invalid;
19495 }
19496
19497 457 tunes_to_read=MAXCUSTOMTUNES;
19498 }
19499
19500
2/2
✓ Branch 0 taken 120960 times.
✓ Branch 1 taken 480 times.
121440 for(int32_t i=0; i<MAXCUSTOMTUNES; ++i)
19501 {
19502
2/2
✓ Branch 0 taken 10262 times.
✓ Branch 1 taken 110698 times.
120960 if(get_bit(mf, i))
19503 {
19504 10262 ++tune_count;
19505 10262 }
19506 120960 }
19507
19508
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 480 times.
480 if (!should_skip)
19509 480 reset_tunes(tunes); //reset_midis(midis);
19510
19511
2/2
✓ Branch 0 taken 116120 times.
✓ Branch 1 taken 480 times.
116600 for(int32_t i=0; i<tunes_to_read; i++)
19512 {
19513 116120 temp.clear(); //memset(&temp_midi,0,sizeof(zcmidi_));
19514
19515
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116120 times.
116120 if (!should_skip)
19516 116120 tunes[i].reset(); // reset_midi(midis+i);
19517
19518
2/2
✓ Branch 0 taken 105858 times.
✓ Branch 1 taken 10262 times.
116120 if(get_bit(mf,i))
19519 {
19520
2/2
✓ Branch 0 taken 2663 times.
✓ Branch 1 taken 7599 times.
10262 if(section_version < 4)
19521 {
19522
1/2
✓ Branch 0 taken 2663 times.
✗ Branch 1 not taken.
2663 if(!p_getstr(temp.title,20,f))
19523 {
19524 return qe_invalid;
19525 }
19526 2663 }
19527 else
19528 {
19529
1/2
✓ Branch 0 taken 7599 times.
✗ Branch 1 not taken.
7599 if(!p_getstr(temp.title,sizeof(temp.title)-1,f))
19530 {
19531 return qe_invalid;
19532 }
19533 }
19534
19535
1/2
✓ Branch 0 taken 10262 times.
✗ Branch 1 not taken.
10262 if(!p_igetl(&temp.start,f))
19536 {
19537 return qe_invalid;
19538 }
19539
19540
1/2
✓ Branch 0 taken 10262 times.
✗ Branch 1 not taken.
10262 if(!p_igetl(&temp.loop_start,f))
19541 {
19542 return qe_invalid;
19543 }
19544
19545
1/2
✓ Branch 0 taken 10262 times.
✗ Branch 1 not taken.
10262 if(!p_igetl(&temp.loop_end,f))
19546 {
19547 return qe_invalid;
19548 }
19549
19550
1/2
✓ Branch 0 taken 10262 times.
✗ Branch 1 not taken.
10262 if(!p_igetw(&temp.loop,f))
19551 {
19552 return qe_invalid;
19553 }
19554
19555
1/2
✓ Branch 0 taken 10262 times.
✗ Branch 1 not taken.
10262 if(!p_igetw(&temp.volume,f))
19556 {
19557 return qe_invalid;
19558 }
19559
19560
2/2
✓ Branch 0 taken 10013 times.
✓ Branch 1 taken 249 times.
10262 if(Header->zelda_version < 0x193)
19561 {
19562
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if(!p_igetl(&dummy,f))
19563 {
19564 return qe_invalid;
19565 }
19566 249 }
19567
19568
2/2
✓ Branch 0 taken 2663 times.
✓ Branch 1 taken 7599 times.
10262 if(section_version >= 3)
19569 {
19570
1/2
✓ Branch 0 taken 7599 times.
✗ Branch 1 not taken.
7599 if(!pfread(&temp.flags,sizeof(temp.flags),f))
19571 {
19572 return qe_invalid;
19573 }
19574 7599 }
19575
19576
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10262 times.
10262 if (!should_skip)
19577 10262 tunes[i].copyfrom(temp); // memcpy(&midis[i], &temp_midi, sizeof(zcmidi_));
19578
19579
2/2
✓ Branch 0 taken 2663 times.
✓ Branch 1 taken 7599 times.
10262 if(section_version < 2) //= 1 || (Header->zelda_version < 0x211) || (Header->zelda_version == 0x211 && Header->build < 18))
19580 {
19581
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2663 times.
2663 if (should_skip)
19582 {
19583 if (read_midi(f)==NULL)
19584 {
19585 return qe_invalid;
19586 }
19587
19588 continue;
19589 }
19590
19591 // old format - a midi is a midi
19592
1/2
✓ Branch 0 taken 2663 times.
✗ Branch 1 not taken.
2663 if((tunes[i].data=read_midi(f))==NULL)
19593 {
19594 return qe_invalid;
19595 }
19596 2663 }
19597 else
19598 {
19599 byte format;
19600
1/2
✓ Branch 0 taken 7599 times.
✗ Branch 1 not taken.
7599 if(!pfread(&format,sizeof(format),f))
19601 {
19602 return qe_invalid;
19603 }
19604
19605 // MIDI is the only format saved here.
19606 // Never did more than MIDI for a zctune, and no plans to now.
19607
1/2
✓ Branch 0 taken 7599 times.
✗ Branch 1 not taken.
7599 if (format != MFORMAT_MIDI)
19608 {
19609 return qe_invalid;
19610 }
19611
19612 7599 tunes[i].data = read_midi(f);
19613
1/2
✓ Branch 0 taken 7599 times.
✗ Branch 1 not taken.
7599 if (!tunes[i].data)
19614 {
19615 return qe_invalid;
19616 }
19617 }
19618 10262 }
19619 116120 }
19620
19621 480 return 0;
19622 480 }
19623
19624 480 int32_t readcheatcodes(PACKFILE *f, zquestheader *Header)
19625 {
19626
2/2
✓ Branch 0 taken 457 times.
✓ Branch 1 taken 23 times.
480 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_cheats);
19627
19628 int32_t dummy;
19629 ZCHEATS tempzcheats;
19630 480 char temp_use_cheats=1;
19631 480 memset(&tempzcheats, 0, sizeof(tempzcheats));
19632 480 word s_version = 0;
19633
19634
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 457 times.
480 if(Header->zelda_version > 0x192)
19635 {
19636 //section version info
19637
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 if(!p_igetw(&s_version,f))
19638 {
19639 return qe_invalid;
19640 }
19641
19642 457 FFCore.quest_format[vCheats] = s_version;
19643
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 if(!p_igetw(&dummy,f))
19644 {
19645 return qe_invalid;
19646 }
19647
19648 //section size
19649
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 if(!p_igetl(&dummy,f))
19650 {
19651 return qe_invalid;
19652 }
19653
19654 //finally... section data
19655
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
457 if(!p_getc(&temp_use_cheats,f))
19656 {
19657 return qe_invalid;
19658 }
19659 457 }
19660
19661
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 480 times.
480 if(Header->data_flags[ZQ_CHEATS2])
19662 {
19663
1/2
✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
480 if(!p_igetl(&tempzcheats.flags,f))
19664 {
19665 return qe_invalid;
19666 }
19667
19668
1/2
✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
480 if(!pfread(&tempzcheats.codes, sizeof(tempzcheats.codes),f))
19669 {
19670 return qe_invalid;
19671 }
19672 480 }
19673
19674
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 480 times.
480 if (should_skip)
19675 return 0;
19676
19677 480 memcpy(&zcheats, &tempzcheats, sizeof(tempzcheats));
19678 480 Header->data_flags[ZQ_CHEATS2]=temp_use_cheats;
19679
19680 480 return 0;
19681 480 }
19682
19683 305 int32_t readinitdata_old(PACKFILE *f, zquestheader *Header, word s_version, zinitdata& temp_zinit)
19684 {
19685
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 282 times.
305 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_initdata);
19686
19687 byte padding, tempbyte;
19688
19689 // Legacy item properties (now integrated into itemdata)
19690 byte sword_hearts[4];
19691 byte beam_hearts[4];
19692 305 byte beam_percent=0;
19693 word beam_power[4];
19694 305 byte hookshot_length=99;
19695 305 byte hookshot_links=100;
19696 305 byte longshot_length=99;
19697 305 byte longshot_links=100;
19698 305 byte moving_fairy_hearts=3;
19699 305 byte moving_fairy_heart_percent=0;
19700 305 byte stationary_fairy_hearts=3;
19701 305 byte stationary_fairy_heart_percent=0;
19702 305 byte moving_fairy_magic=0;
19703 305 byte moving_fairy_magic_percent=0;
19704 305 byte stationary_fairy_magic=0;
19705 305 byte stationary_fairy_magic_percent=0;
19706 305 byte blue_potion_hearts=100;
19707 305 byte blue_potion_heart_percent=1;
19708 305 byte red_potion_hearts=100;
19709 305 byte red_potion_heart_percent=1;
19710 305 byte blue_potion_magic=100;
19711 305 byte blue_potion_magic_percent=1;
19712 305 byte red_potion_magic=100;
19713 305 byte red_potion_magic_percent=1;
19714
19715 305 byte bomb_ratio = 4;
19716
19717 305 subscr_mode = 0;
19718
19719 /* HIGHLY UNORTHODOX UPDATING THING, by L
19720 * This fixes quests made before revision 277 (such as the 'Lost Isle Build'),
19721 * where the speed of Pols Voice changed. It also coincided with V_INITDATA
19722 * changing from 13 to 14.
19723 */
19724
2/2
✓ Branch 0 taken 223 times.
✓ Branch 1 taken 82 times.
305 if(s_version < 14)
19725 82 fixpolsvoice=true;
19726
19727 /* End highly unorthodox updating thing */
19728
19729
4/4
✓ Branch 0 taken 223 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 109 times.
✓ Branch 3 taken 114 times.
305 if(s_version >= 15 && get_bit(deprecated_rules, 27)) // The int16_t-lived rule, qr_JUMPHEROLAYER3
19730 114 temp_zinit.jump_hero_layer_threshold=0;
19731
19732
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 223 times.
305 if(s_version >= 10)
19733 {
19734 char temp;
19735
19736 //new-style items
19737
2/2
✓ Branch 0 taken 57088 times.
✓ Branch 1 taken 223 times.
57311 for(int32_t j=0; j<256; j++)
19738 {
19739
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 57088 times.
57088 if(!p_getc(&temp,f))
19740 return qe_invalid;
19741
19742 57088 temp_zinit.set_item(j, temp != 0);
19743 57088 }
19744 223 }
19745
19746
5/6
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 282 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 18 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
305 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>26)))
19747 {
19748 char temp;
19749
19750 //finally... section data
19751
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 282 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
292 if((Header->zelda_version > 0x192)||
19752 //new only
19753
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 ((Header->zelda_version == 0x192)&&(Header->build>173)))
19754 {
19755 //OLD-style items... sigh
19756
2/2
✓ Branch 0 taken 223 times.
✓ Branch 1 taken 60 times.
283 if(s_version < 10)
19757 {
19758
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19759 {
19760 return qe_invalid;
19761 }
19762
19763 60 temp_zinit.set_item(iRaft, temp != 0);
19764
19765
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19766 {
19767 return qe_invalid;
19768 }
19769
19770 60 temp_zinit.set_item(iLadder, temp != 0);
19771
19772
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19773 {
19774 return qe_invalid;
19775 }
19776
19777 60 temp_zinit.set_item(iBook, temp != 0);
19778
19779
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19780 {
19781 return qe_invalid;
19782 }
19783
19784 60 temp_zinit.set_item(iMKey, temp != 0);
19785
19786
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19787 {
19788 return qe_invalid;
19789 }
19790
19791 60 temp_zinit.set_item(iFlippers, temp != 0);
19792
19793
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19794 {
19795 return qe_invalid;
19796 }
19797
19798 60 temp_zinit.set_item(iBoots, temp != 0);
19799 60 }
19800 283 }
19801
19802
2/2
✓ Branch 0 taken 223 times.
✓ Branch 1 taken 64 times.
287 if(s_version < 10)
19803 {
19804 char tempring, tempsword, tempshield, tempwallet, tempbracelet, tempamulet, tempbow;
19805
19806
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempring,f))
19807 {
19808 return qe_invalid;
19809 }
19810
19811
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempsword,f))
19812 {
19813 return qe_invalid;
19814 }
19815
19816
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempshield,f))
19817 {
19818 return qe_invalid;
19819 }
19820
19821
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempwallet,f))
19822 {
19823 return qe_invalid;
19824 }
19825
19826
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempbracelet,f))
19827 {
19828 return qe_invalid;
19829 }
19830
19831
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempamulet,f))
19832 {
19833 return qe_invalid;
19834 }
19835
19836
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempbow,f))
19837 {
19838 return qe_invalid;
19839 }
19840
19841 //old only
19842
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
64 if((Header->zelda_version == 0x192)&&(Header->build<174))
19843 {
19844
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempring=(tempring)?(1<<(tempring-1)):0;
19845
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempsword=(tempsword)?(1<<(tempsword-1)):0;
19846
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 tempshield=(tempshield)?(1<<(tempshield-1)):0;
19847
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempwallet=(tempwallet)?(1<<(tempwallet-1)):0;
19848
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempbracelet=(tempbracelet)?(1<<(tempbracelet-1)):0;
19849
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempamulet=(tempamulet)?(1<<(tempamulet-1)):0;
19850
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempbow=(tempbow)?(1<<(tempbow-1)):0;
19851 4 }
19852
19853 //rings start at level 2... wtf
19854 //account for this -DD
19855 64 tempring <<= 1;
19856 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_ring, tempring);
19857 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_sword, tempsword);
19858 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_shield, tempshield);
19859 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_wallet, tempwallet);
19860 //bracelet ALSO starts at level 2 :-( -DD
19861 64 tempbracelet<<=1;
19862 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bracelet, tempbracelet);
19863 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_amulet, tempamulet);
19864 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bow, tempbow);
19865
19866 //new only
19867
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 1 times.
64 if((Header->zelda_version == 0x192)&&(Header->build>173))
19868 {
19869
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 1 times.
33 for(int32_t q=0; q<32; q++)
19870 {
19871
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 if(!p_getc(&padding,f))
19872 {
19873 return qe_invalid;
19874 }
19875 32 }
19876 1 }
19877
19878 char tempcandle, tempboomerang, temparrow, tempwhistle;
19879
19880
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempcandle,f))
19881 {
19882 return qe_invalid;
19883 }
19884
19885
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempboomerang,f))
19886 {
19887 return qe_invalid;
19888 }
19889
19890
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&temparrow,f))
19891 {
19892 return qe_invalid;
19893 }
19894
19895
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&temp,f))
19896 {
19897 return qe_invalid;
19898 }
19899
19900 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_potion, temp);
19901
19902
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempwhistle,f))
19903 {
19904 return qe_invalid;
19905 }
19906
19907 //old only
19908
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
64 if((Header->zelda_version == 0x192)&&(Header->build<174))
19909 {
19910
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempcandle=(tempcandle)?(1<<(tempcandle-1)):0;
19911
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempboomerang=(tempboomerang)?(1<<(tempboomerang-1)):0;
19912
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 temparrow=(temparrow)?(1<<(temparrow-1)):0;
19913
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempwhistle=(tempwhistle)?(1<<(tempwhistle-1)):0;
19914 4 }
19915
19916 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_candle, tempcandle);
19917 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_brang, tempboomerang);
19918 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_arrow, temparrow);
19919 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_whistle, tempwhistle);
19920 //What about the potion...?
19921
19922 64 }
19923
19924
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 270 times.
287 if(s_version < 29)
19925 {
19926 //Oh sure, stick these IN THE MIDDLE OF THE ITEMS, just to make me want
19927 //to jab out my eye...
19928
1/2
✓ Branch 0 taken 270 times.
✗ Branch 1 not taken.
270 if(!p_getc(&padding,f))
19929 return qe_invalid;
19930 270 temp_zinit.counter[crBOMBS] = padding;
19931
19932
1/2
✓ Branch 0 taken 270 times.
✗ Branch 1 not taken.
270 if(!p_getc(&padding,f))
19933 return qe_invalid;
19934 270 temp_zinit.counter[crSBOMBS] = padding;
19935 270 }
19936
19937 //Back to more OLD item code
19938
2/2
✓ Branch 0 taken 223 times.
✓ Branch 1 taken 64 times.
287 if(s_version < 10)
19939 {
19940
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
69 if((Header->zelda_version > 0x192)||
19941 //new only
19942
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 ((Header->zelda_version == 0x192)&&(Header->build>173)))
19943 {
19944
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19945 {
19946 return qe_invalid;
19947 }
19948
19949 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_wand, temp);
19950
19951
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19952 {
19953 return qe_invalid;
19954 }
19955
19956 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_letter, temp);
19957
19958
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19959 {
19960 return qe_invalid;
19961 }
19962
19963 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_lens, temp);
19964
19965
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19966 {
19967 return qe_invalid;
19968 }
19969
19970 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_hookshot, temp);
19971
19972
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19973 {
19974 return qe_invalid;
19975 }
19976
19977 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bait, temp);
19978
19979
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19980 {
19981 return qe_invalid;
19982 }
19983
19984 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_hammer, temp);
19985
19986
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19987 {
19988 return qe_invalid;
19989 }
19990
19991 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divinefire, temp);
19992
19993
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19994 {
19995 return qe_invalid;
19996 }
19997
19998 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divineescape, temp);
19999
20000
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
20001 {
20002 return qe_invalid;
20003 }
20004
20005 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divineprotection, temp);
20006
20007
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
20008 {
20009 return qe_invalid;
20010 }
20011
20012
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 1 times.
60 if(Header->zelda_version == 0x192)
20013 {
20014
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 1 times.
33 for(int32_t q=0; q<32; q++)
20015 {
20016
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 if(!p_getc(&padding,f))
20017 {
20018 return qe_invalid;
20019 }
20020 32 }
20021 1 }
20022 60 }
20023 64 }
20024
20025 //old only
20026
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 282 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
287 if((Header->zelda_version == 0x192)&&(Header->build<174))
20027 {
20028 byte equipment, tmpitm; //bit flags
20029
20030
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&equipment,f))
20031 {
20032 return qe_invalid;
20033 }
20034
20035 4 temp_zinit.set_item(iRaft, get_bit(&equipment, idE_RAFT)!=0);
20036 4 temp_zinit.set_item(iLadder, get_bit(&equipment, idE_LADDER)!=0);
20037 4 temp_zinit.set_item(iBook, get_bit(&equipment, idE_BOOK)!=0);
20038 4 temp_zinit.set_item(iMKey, get_bit(&equipment, idE_KEY)!=0);
20039 4 temp_zinit.set_item(iFlippers, get_bit(&equipment, idE_FLIPPERS)!=0);
20040 4 temp_zinit.set_item(iBoots, get_bit(&equipment, idE_BOOTS)!=0);
20041
20042
20043
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tmpitm,f))
20044 {
20045 return qe_invalid;
20046 }
20047
20048 4 temp_zinit.set_item(iWand, get_bit(&tmpitm, idI_WAND)!=0);
20049 4 temp_zinit.set_item(iLetter, get_bit(&tmpitm, idI_LETTER)!=0);
20050 4 temp_zinit.set_item(iLens, get_bit(&tmpitm, idI_LENS)!=0);
20051 4 temp_zinit.set_item(iHookshot, get_bit(&tmpitm, idI_HOOKSHOT)!=0);
20052 4 temp_zinit.set_item(iBait, get_bit(&tmpitm, idI_BAIT)!=0);
20053 4 temp_zinit.set_item(iHammer, get_bit(&tmpitm, idI_HAMMER)!=0);
20054 4 }
20055
20056
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if(!p_getc(&tempbyte,f))
20057 return qe_invalid;
20058 287 temp_zinit.mcounter[crLIFE] = tempbyte;
20059
20060
20061
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 223 times.
287 if(s_version < 14)
20062 {
20063 byte temphp;
20064
20065
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&temphp,f))
20066 {
20067 return qe_invalid;
20068 }
20069
20070 64 temp_zinit.counter[crLIFE]=temphp;
20071
20072
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&temphp,f))
20073 {
20074 return qe_invalid;
20075 }
20076
20077 64 temp_zinit.cont_heart=temphp;
20078 64 }
20079 else
20080 {
20081
1/2
✓ Branch 0 taken 223 times.
✗ Branch 1 not taken.
223 if(!p_igetw(&temp_zinit.counter[crLIFE],f))
20082 {
20083 return qe_invalid;
20084 }
20085
20086
1/2
✓ Branch 0 taken 223 times.
✗ Branch 1 not taken.
223 if(!p_igetw(&temp_zinit.cont_heart,f))
20087 {
20088 return qe_invalid;
20089 }
20090 }
20091
20092
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if(!p_getc(&temp_zinit.hcp,f))
20093 {
20094 return qe_invalid;
20095 }
20096
20097
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 223 times.
287 if(s_version >= 14)
20098 {
20099
1/2
✓ Branch 0 taken 223 times.
✗ Branch 1 not taken.
223 if(!p_getc(&temp_zinit.hcp_per_hc,f))
20100 {
20101 return qe_invalid;
20102 }
20103
20104
1/2
✓ Branch 0 taken 223 times.
✗ Branch 1 not taken.
223 if(s_version<16) // July 2007
20105 {
20106 if(get_qr(qr_BRANGPICKUP+1))
20107 temp_zinit.hcp_per_hc = 0xFF;
20108
20109 //Dispose of legacy rule
20110 set_qr(qr_BRANGPICKUP+1, 0);
20111 }
20112 223 }
20113
20114
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 270 times.
287 if(s_version < 29)
20115 {
20116
1/2
✓ Branch 0 taken 270 times.
✗ Branch 1 not taken.
270 if(!p_getc(&padding,f))
20117 return qe_invalid;
20118 270 temp_zinit.mcounter[crBOMBS] = padding;
20119 270 }
20120
20121
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if(!p_getc(&temp_zinit.counter[crKEYS],f))
20122 {
20123 return qe_invalid;
20124 }
20125
20126
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if(!p_igetw(&temp_zinit.counter[crMONEY],f))
20127 {
20128 return qe_invalid;
20129 }
20130
20131
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if(!p_getc(&tempbyte,f))
20132 return qe_invalid;
20133
2/2
✓ Branch 0 taken 2296 times.
✓ Branch 1 taken 287 times.
2583 for(int q = 0; q < 8; ++q)
20134
2/2
✓ Branch 0 taken 504 times.
✓ Branch 1 taken 1792 times.
2296 SETFLAG(temp_zinit.litems[q+1], liTRIFORCE, get_bitl(tempbyte, q));
20135
20136 287 int level_count = 32;
20137
3/6
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 223 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 64 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
287 if(s_version>12 || (Header->zelda_version == 0x211 && Header->build == 18))
20138 223 level_count = 64;
20139 byte tmp_map[64];
20140 byte tmp_compass[64];
20141
2/2
✓ Branch 0 taken 16320 times.
✓ Branch 1 taken 287 times.
16607 for(int32_t i=0; i<level_count; i++)
20142
1/2
✓ Branch 0 taken 16320 times.
✗ Branch 1 not taken.
16320 if(!p_getc(&tmp_map[i],f))
20143 return qe_invalid;
20144
2/2
✓ Branch 0 taken 16320 times.
✓ Branch 1 taken 287 times.
16607 for(int32_t i=0; i<level_count; i++)
20145
1/2
✓ Branch 0 taken 16320 times.
✗ Branch 1 not taken.
16320 if(!p_getc(&tmp_compass[i],f))
20146 return qe_invalid;
20147
2/2
✓ Branch 0 taken 130560 times.
✓ Branch 1 taken 287 times.
130847 for(int q = 0; q < level_count*8; ++q)
20148 {
20149
2/2
✓ Branch 0 taken 796 times.
✓ Branch 1 taken 129764 times.
130560 SETFLAG(temp_zinit.litems[q], liMAP, get_bit(tmp_map, q));
20150
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 130551 times.
130560 SETFLAG(temp_zinit.litems[q], liCOMPASS, get_bit(tmp_compass, q));
20151 130560 }
20152
20153
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 282 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
292 if((Header->zelda_version > 0x192)||
20154 //new only
20155
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 ((Header->zelda_version == 0x192)&&(Header->build>173)))
20156 {
20157 byte tmp_boss_key[64];
20158
2/2
✓ Branch 0 taken 16192 times.
✓ Branch 1 taken 283 times.
16475 for(int32_t i=0; i<level_count; i++)
20159 {
20160
1/2
✓ Branch 0 taken 16192 times.
✗ Branch 1 not taken.
16192 if(!p_getc(&tmp_boss_key[i],f))
20161 {
20162 return qe_invalid;
20163 }
20164 16192 }
20165
2/2
✓ Branch 0 taken 129536 times.
✓ Branch 1 taken 283 times.
129819 for(int q = 0; q < level_count*8; ++q)
20166 {
20167
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129536 times.
129536 SETFLAG(temp_zinit.litems[q], liBOSSKEY, get_bit(tmp_boss_key, q));
20168 129536 }
20169 283 }
20170
20171 byte tmpmisc[16];
20172
2/2
✓ Branch 0 taken 4592 times.
✓ Branch 1 taken 287 times.
4879 for(int32_t i=0; i<16; i++)
20173
1/2
✓ Branch 0 taken 4592 times.
✗ Branch 1 not taken.
4592 if(!p_getc(&tmpmisc[i],f))
20174 return qe_invalid;
20175 287 temp_zinit.flags.set(INIT_FL_CONTPERCENT,get_bit(tmpmisc,0));
20176 287 temp_zinit.magicdrainrate = get_bit(tmpmisc,1) ? 1 : 2; //Double Magic flag
20177 287 temp_zinit.flags.set(INIT_FL_CANSLASH,get_bit(tmpmisc,2));
20178
20179
4/4
✓ Branch 0 taken 223 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 256 times.
✓ Branch 3 taken 64 times.
543 if(s_version < 15) for(int32_t i=0; i<4; i++)
20180
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(!p_getc(&sword_hearts[i],f))
20181 64 return qe_invalid;
20182
20183
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if(!p_getc(&temp_zinit.last_map,f))
20184 {
20185 return qe_invalid;
20186 }
20187
20188
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if(!p_getc(&temp_zinit.last_screen,f))
20189 {
20190 return qe_invalid;
20191 }
20192
20193
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 223 times.
287 if(s_version < 14)
20194 {
20195 byte tempmp;
20196
20197
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempmp,f))
20198 {
20199 return qe_invalid;
20200 }
20201
20202 64 temp_zinit.mcounter[crMAGIC]=tempmp;
20203
20204
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempmp,f))
20205 {
20206 return qe_invalid;
20207 }
20208
20209 64 temp_zinit.counter[crMAGIC]=tempmp;
20210 64 }
20211 else
20212 {
20213
1/2
✓ Branch 0 taken 223 times.
✗ Branch 1 not taken.
223 if(!p_igetw(&temp_zinit.mcounter[crMAGIC],f))
20214 {
20215 return qe_invalid;
20216 }
20217
20218
1/2
✓ Branch 0 taken 223 times.
✗ Branch 1 not taken.
223 if(!p_igetw(&temp_zinit.counter[crMAGIC],f))
20219 {
20220 return qe_invalid;
20221 }
20222 }
20223
20224
20225
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 223 times.
287 if(s_version < 15)
20226 {
20227
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
64 if(s_version < 12)
20228 {
20229 64 temp_zinit.mcounter[crMAGIC]*=32;
20230 64 temp_zinit.counter[crMAGIC]*=32;
20231 64 }
20232
20233
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 64 times.
320 for(int32_t i=0; i<4; i++)
20234 {
20235
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(!p_getc(&beam_hearts[i],f))
20236 {
20237 return qe_invalid;
20238 }
20239 256 }
20240
20241
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&beam_percent,f))
20242 {
20243 return qe_invalid;
20244 }
20245 64 }
20246 else
20247 {
20248
1/2
✓ Branch 0 taken 223 times.
✗ Branch 1 not taken.
223 if(!p_getc(&temp_zinit.bomb_ratio,f))
20249 return qe_invalid;
20250
1/2
✓ Branch 0 taken 223 times.
✗ Branch 1 not taken.
223 if(temp_zinit.bomb_ratio < 1)
20251 temp_zinit.bomb_ratio = 1;
20252 223 else bomb_ratio = temp_zinit.bomb_ratio; //jank
20253 }
20254
20255
2/2
✓ Branch 0 taken 223 times.
✓ Branch 1 taken 64 times.
287 if(s_version < 15)
20256 {
20257 byte tempbp;
20258
20259
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 64 times.
320 for(int32_t i=0; i<4; i++)
20260 {
20261
2/4
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 256 times.
✗ Branch 3 not taken.
256 if(!(s_version < 14 ? p_getc(&tempbp,f) : p_igetw(&tempbp,f)))
20262 {
20263 return qe_invalid;
20264 }
20265
20266 256 beam_power[i]=tempbp;
20267 256 }
20268
20269
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&hookshot_links,f))
20270 {
20271 return qe_invalid;
20272 }
20273
20274
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(s_version>6)
20275 {
20276 if(!p_getc(&hookshot_length,f))
20277 {
20278 return qe_invalid;
20279 }
20280
20281 if(!p_getc(&longshot_links,f))
20282 {
20283 return qe_invalid;
20284 }
20285
20286 if(!p_getc(&longshot_length,f))
20287 {
20288 return qe_invalid;
20289 }
20290 }
20291 64 }
20292
20293
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if(!p_getc(&temp_zinit.msg_more_x,f))
20294 {
20295 return qe_invalid;
20296 }
20297
20298
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if(!p_getc(&temp_zinit.msg_more_y,f))
20299 {
20300 return qe_invalid;
20301 }
20302
20303
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if(!p_getc(&subscr_mode,f))
20304 return qe_invalid;
20305
20306 //old only
20307
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 282 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
287 if((Header->zelda_version == 0x192)&&(Header->build<174))
20308 {
20309 byte tmp_boss_key[32];
20310
2/2
✓ Branch 0 taken 128 times.
✓ Branch 1 taken 4 times.
132 for(int32_t i=0; i<32; i++)
20311 {
20312
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(!p_getc(&tmp_boss_key[i],f))
20313 {
20314 return qe_invalid;
20315 }
20316 128 }
20317
2/2
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 4 times.
1028 for(int q = 0; q < 32*8; ++q)
20318 {
20319
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1024 times.
1024 SETFLAG(temp_zinit.litems[q], liBOSSKEY, get_bit(tmp_boss_key, q));
20320 1024 }
20321 4 }
20322
20323
5/6
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 282 times.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 4 times.
287 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>173))) //new only
20324 {
20325
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 223 times.
283 if(s_version <= 10)
20326 {
20327
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&tempbyte,f))
20328 {
20329 return qe_invalid;
20330 }
20331
20332 60 temp_zinit.start_dmap = (word)tempbyte;
20333 60 }
20334 else
20335 {
20336
1/2
✓ Branch 0 taken 223 times.
✗ Branch 1 not taken.
223 if(!p_igetw(&temp_zinit.start_dmap,f))
20337 {
20338 return qe_invalid;
20339 }
20340 }
20341
20342
1/2
✓ Branch 0 taken 283 times.
✗ Branch 1 not taken.
283 if(!p_getc(&temp_zinit.heroAnimationStyle,f))
20343 {
20344 return qe_invalid;
20345 }
20346 283 }
20347
20348
4/4
✓ Branch 0 taken 223 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 17 times.
✓ Branch 3 taken 206 times.
287 if(s_version>1 && s_version < 29)
20349 {
20350
1/2
✓ Branch 0 taken 206 times.
✗ Branch 1 not taken.
206 if(!p_getc(&padding,f))
20351 return qe_invalid;
20352 206 temp_zinit.counter[crARROWS] = padding;
20353
20354
1/2
✓ Branch 0 taken 206 times.
✗ Branch 1 not taken.
206 if(!p_getc(&padding,f))
20355 return qe_invalid;
20356 206 temp_zinit.mcounter[crARROWS] = padding;
20357 206 }
20358
20359
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 223 times.
287 if(s_version>2)
20360 {
20361
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 223 times.
223 if(s_version <= 10)
20362 {
20363 for(int32_t i=0; i<OLDMAXLEVELS; i++)
20364 {
20365 if(!p_getc(&(temp_zinit.level_keys[i]),f))
20366 {
20367 return qe_invalid;
20368 }
20369 }
20370 }
20371 else
20372 {
20373
2/2
✓ Branch 0 taken 114176 times.
✓ Branch 1 taken 223 times.
114399 for(int32_t i=0; i<MAXLEVELS; i++)
20374 {
20375
1/2
✓ Branch 0 taken 114176 times.
✗ Branch 1 not taken.
114176 if(!p_getc(&(temp_zinit.level_keys[i]),f))
20376 {
20377 return qe_invalid;
20378 }
20379 114176 }
20380 }
20381 223 }
20382
20383
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 223 times.
287 if(s_version>3)
20384 {
20385
1/2
✓ Branch 0 taken 223 times.
✗ Branch 1 not taken.
223 if(!p_igetw(&temp_zinit.ss_grid_x,f))
20386 {
20387 return qe_invalid;
20388 }
20389
20390
1/2
✓ Branch 0 taken 223 times.
✗ Branch 1 not taken.
223 if(!p_igetw(&temp_zinit.ss_grid_y,f))
20391 {
20392 return qe_invalid;
20393 }
20394
20395
1/2
✓ Branch 0 taken 223 times.
✗ Branch 1 not taken.
223 if(!p_igetw(&temp_zinit.ss_grid_xofs,f))
20396 {
20397 return qe_invalid;
20398 }
20399
20400
1/2
✓ Branch 0 taken 223 times.
✗ Branch 1 not taken.
223 if(!p_igetw(&temp_zinit.ss_grid_yofs,f))
20401 {
20402 return qe_invalid;
20403 }
20404
20405
1/2
✓ Branch 0 taken 223 times.
✗ Branch 1 not taken.
223 if(!p_igetw(&temp_zinit.ss_grid_color,f))
20406 {
20407 return qe_invalid;
20408 }
20409
20410
1/2
✓ Branch 0 taken 223 times.
✗ Branch 1 not taken.
223 if(!p_igetw(&temp_zinit.ss_bbox_1_color,f))
20411 {
20412 return qe_invalid;
20413 }
20414
20415
1/2
✓ Branch 0 taken 223 times.
✗ Branch 1 not taken.
223 if(!p_igetw(&temp_zinit.ss_bbox_2_color,f))
20416 {
20417 return qe_invalid;
20418 }
20419
20420
1/2
✓ Branch 0 taken 223 times.
✗ Branch 1 not taken.
223 if(!p_igetw(&temp_zinit.ss_flags,f))
20421 {
20422 return qe_invalid;
20423 }
20424
20425
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 223 times.
223 temp_zinit.ss_grid_x=zc_max(temp_zinit.ss_grid_x,1);
20426
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 223 times.
223 temp_zinit.ss_grid_y=zc_max(temp_zinit.ss_grid_y,1);
20427 223 }
20428
20429
3/4
✓ Branch 0 taken 223 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 223 times.
✗ Branch 3 not taken.
287 if(s_version>4 && s_version<15)
20430 {
20431 if(!p_getc(&moving_fairy_hearts,f))
20432 {
20433 return qe_invalid;
20434 }
20435
20436 if(!p_getc(&moving_fairy_heart_percent,f))
20437 {
20438 return qe_invalid;
20439 }
20440 }
20441
20442
3/4
✓ Branch 0 taken 223 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 223 times.
✗ Branch 3 not taken.
287 if(s_version>5 && s_version < 10)
20443 {
20444 if(!p_getc(&temp,f))
20445 {
20446 return qe_invalid;
20447 }
20448
20449 addOldStyleFamily(&temp_zinit, itemsbuf, itype_quiver, temp);
20450 }
20451
20452
3/4
✓ Branch 0 taken 223 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 223 times.
✗ Branch 3 not taken.
287 if(s_version>6 && s_version<15)
20453 {
20454 if(!p_getc(&stationary_fairy_hearts,f))
20455 {
20456 return qe_invalid;
20457 }
20458
20459 if(!p_getc(&stationary_fairy_heart_percent,f))
20460 {
20461 return qe_invalid;
20462 }
20463
20464 if(!p_getc(&moving_fairy_magic,f))
20465 {
20466 return qe_invalid;
20467 }
20468
20469 if(!p_getc(&moving_fairy_magic_percent,f))
20470 {
20471 return qe_invalid;
20472 }
20473
20474 if(!p_getc(&stationary_fairy_magic,f))
20475 {
20476 return qe_invalid;
20477 }
20478
20479 if(!p_getc(&stationary_fairy_magic_percent,f))
20480 {
20481 return qe_invalid;
20482 }
20483
20484 if(!p_getc(&blue_potion_hearts,f))
20485 {
20486 return qe_invalid;
20487 }
20488
20489 if(!p_getc(&blue_potion_heart_percent,f))
20490 {
20491 return qe_invalid;
20492 }
20493
20494 if(!p_getc(&red_potion_hearts,f))
20495 {
20496 return qe_invalid;
20497 }
20498
20499 if(!p_getc(&red_potion_heart_percent,f))
20500 {
20501 return qe_invalid;
20502 }
20503
20504 if(!p_getc(&blue_potion_magic,f))
20505 {
20506 return qe_invalid;
20507 }
20508
20509 if(!p_getc(&blue_potion_magic_percent,f))
20510 {
20511 return qe_invalid;
20512 }
20513
20514 if(!p_getc(&red_potion_magic,f))
20515 {
20516 return qe_invalid;
20517 }
20518
20519 if(!p_getc(&red_potion_magic_percent,f))
20520 {
20521 return qe_invalid;
20522 }
20523 }
20524
20525
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 223 times.
287 if(s_version>6)
20526
1/2
✓ Branch 0 taken 223 times.
✗ Branch 1 not taken.
223 if(!p_getc(&padding,f))
20527 return qe_invalid;
20528
20529
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 223 times.
287 if(s_version>7)
20530 {
20531
1/2
✓ Branch 0 taken 223 times.
✗ Branch 1 not taken.
223 if(!p_getc(&padding,f))
20532 {
20533 return qe_invalid;
20534 }
20535 223 }
20536
20537
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 223 times.
287 if(s_version>8)
20538 {
20539
1/2
✓ Branch 0 taken 223 times.
✗ Branch 1 not taken.
223 if(!p_igetw(&temp_zinit.mcounter[crMONEY],f))
20540 {
20541 return qe_invalid;
20542 }
20543
20544
1/2
✓ Branch 0 taken 223 times.
✗ Branch 1 not taken.
223 if(!p_igetw(&temp_zinit.mcounter[crKEYS],f))
20545 {
20546 return qe_invalid;
20547 }
20548 223 }
20549
20550
2/2
✓ Branch 0 taken 223 times.
✓ Branch 1 taken 64 times.
287 if(s_version>16)
20551 {
20552
1/2
✓ Branch 0 taken 223 times.
✗ Branch 1 not taken.
223 if(!p_getc(&tempbyte,f))
20553 {
20554 return qe_invalid;
20555 }
20556 223 temp_zinit.gravity = tempbyte*100;
20557
1/2
✓ Branch 0 taken 223 times.
✗ Branch 1 not taken.
223 if(!p_igetw(&temp_zinit.terminalv,f))
20558 {
20559 return qe_invalid;
20560 }
20561
20562
1/2
✓ Branch 0 taken 223 times.
✗ Branch 1 not taken.
223 if(!p_getc(&temp_zinit.msg_speed,f))
20563 {
20564 return qe_invalid;
20565 }
20566
20567
1/2
✓ Branch 0 taken 223 times.
✗ Branch 1 not taken.
223 if(!p_getc(&padding,f))
20568 {
20569 return qe_invalid;
20570 }
20571
20572
1/2
✓ Branch 0 taken 223 times.
✗ Branch 1 not taken.
223 if(!p_getc(&temp_zinit.jump_hero_layer_threshold,f))
20573 {
20574 return qe_invalid;
20575 }
20576 223 }
20577
2/2
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 12 times.
64 else if (replay_version_check(0, 13))
20578 12 temp_zinit.msg_speed = 0;
20579
20580
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 223 times.
287 if(s_version>17)
20581 {
20582
1/2
✓ Branch 0 taken 223 times.
✗ Branch 1 not taken.
223 if(!p_getc(&temp_zinit.msg_more_is_offset,f))
20583 {
20584 return qe_invalid;
20585 }
20586 223 }
20587
20588 //expaned init data for larger values in 2.55
20589
2/2
✓ Branch 0 taken 270 times.
✓ Branch 1 taken 17 times.
287 if ( s_version >= 19 ) //expand init data bombs, sbombs, and arrows to 0xFFFF
20590 {
20591
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.counter[crBOMBS],f))
20592 {
20593 return qe_invalid;
20594 }
20595
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.counter[crSBOMBS],f))
20596 {
20597 return qe_invalid;
20598 }
20599
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.mcounter[crBOMBS],f))
20600 {
20601 return qe_invalid;
20602 }
20603
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.mcounter[crSBOMBS],f))
20604 {
20605 return qe_invalid;
20606 }
20607
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.counter[crARROWS],f))
20608 {
20609 return qe_invalid;
20610 }
20611
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.mcounter[crARROWS],f))
20612 {
20613 return qe_invalid;
20614 }
20615
20616 17 }
20617
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 270 times.
287 if ( s_version >= 20 )
20618 {
20619
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.heroStep,f))
20620 {
20621 return qe_invalid;
20622 }
20623 17 }
20624 else
20625 {
20626 270 temp_zinit.heroStep = 150; //1.5 pixels per frame
20627 }
20628
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 270 times.
287 if ( s_version >= 21 )
20629 {
20630
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.subscrSpeed,f))
20631 {
20632 return qe_invalid;
20633 }
20634 17 }
20635 else
20636 {
20637 270 temp_zinit.subscrSpeed = 1; //3 pixels per frame
20638 }
20639 //old only
20640
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 282 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
287 if((Header->zelda_version == 0x192)&&(Header->build<174))
20641 {
20642 byte items2;
20643
20644
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&items2,f))
20645 {
20646 return qe_invalid;
20647 }
20648
20649 4 temp_zinit.set_item(iDivineFire, get_bit(&items2, idI_DFIRE)!=0);
20650 4 temp_zinit.set_item(iDivineEscape, get_bit(&items2, idI_FWIND)!=0);
20651 4 temp_zinit.set_item(iDivineProtection, get_bit(&items2, idI_NLOVE)!=0);
20652 4 }
20653
20654
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 5 times.
287 if(Header->zelda_version < 0x193)
20655 {
20656
2/2
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 5 times.
485 for(int32_t q=0; q<96; q++)
20657 {
20658
1/2
✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
480 if(!p_getc(&padding,f))
20659 {
20660 return qe_invalid;
20661 }
20662 480 }
20663
20664 //new only
20665
3/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 1 times.
5 if((Header->zelda_version == 0x192)&&(Header->build>173))
20666 {
20667
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!p_getc(&padding,f))
20668 {
20669 return qe_invalid;
20670 }
20671
20672
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!p_getc(&padding,f))
20673 {
20674 return qe_invalid;
20675 }
20676 1 }
20677 5 }
20678 287 }
20679
20680
3/6
✓ Branch 0 taken 223 times.
✓ Branch 1 taken 82 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 223 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
305 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<15)))
20681 {
20682 //temp_zinit.shield=i_smallshield;
20683 82 int32_t sshieldid = getItemID(itemsbuf, itype_shield, i_smallshield);
20684
20685
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if(sshieldid != -1)
20686 82 temp_zinit.set_item(sshieldid, true);
20687 82 }
20688
20689
5/6
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 282 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
305 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<27)))
20690 {
20691 18 temp_zinit.mcounter[crLIFE]=3;
20692 18 temp_zinit.counter[crLIFE]=3;
20693 18 temp_zinit.cont_heart=3;
20694 18 temp_zinit.mcounter[crBOMBS]=8;
20695 18 }
20696
20697
5/6
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 282 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
305 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<50)))
20698 {
20699 18 sword_hearts[0]=0;
20700 18 sword_hearts[1]=5;
20701 18 sword_hearts[2]=12;
20702 18 sword_hearts[3]=21;
20703 18 }
20704
20705
5/6
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 282 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
305 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<51)))
20706 {
20707 18 temp_zinit.last_map=0;
20708 18 temp_zinit.last_screen=0;
20709 18 }
20710
20711
5/6
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 282 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
305 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<68)))
20712 {
20713 18 temp_zinit.mcounter[crMAGIC]=0;
20714 18 temp_zinit.counter[crMAGIC]=0;
20715 18 temp_zinit.magicdrainrate = 2;
20716 18 }
20717
20718
5/6
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 282 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
305 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<129)))
20719 {
20720
20721
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
90 for(int32_t x=0; x<4; x++)
20722 {
20723 72 beam_hearts[x]=100;
20724 72 }
20725
20726
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
90 for(int32_t i=0; i<idBP_MAX; i++)
20727 {
20728 72 set_bit(&beam_percent,i,!get_qr(qr_LENSHINTS+i));
20729 72 set_qr(qr_LENSHINTS+i,0);
20730 72 }
20731
20732
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
90 for(int32_t x=0; x<4; x++)
20733 {
20734 72 beam_power[x]=get_qr(qr_HIDECARRIEDITEMS)?50:100;
20735 72 }
20736
20737 18 set_qr(qr_HIDECARRIEDITEMS,0);
20738 18 hookshot_links=100;
20739 18 temp_zinit.msg_more_x=224;
20740 18 temp_zinit.msg_more_y=64;
20741 18 }
20742
20743 // Okay, let's put these legacy values into itemsbuf.
20744
2/2
✓ Branch 0 taken 223 times.
✓ Branch 1 taken 82 times.
305 if(s_version < 15)
20745
2/2
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 82 times.
21074 for(int32_t i=0; i<MAXITEMS; i++)
20746 {
20747
11/11
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 82 times.
✓ Branch 4 taken 82 times.
✓ Branch 5 taken 82 times.
✓ Branch 6 taken 82 times.
✓ Branch 7 taken 82 times.
✓ Branch 8 taken 20172 times.
✓ Branch 9 taken 82 times.
✓ Branch 10 taken 82 times.
20992 switch(i)
20748 {
20749 case iFairyStill:
20750 82 itemsbuf[i].misc1 = stationary_fairy_hearts;
20751 82 itemsbuf[i].misc2 = stationary_fairy_magic;
20752 82 itemsbuf[i].misc3 = 0;
20753
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if (stationary_fairy_heart_percent) itemsbuf[i].flags |= item_flag1;
20754
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if (stationary_fairy_magic_percent) itemsbuf[i].flags |= item_flag2;
20755 82 break;
20756
20757 case iFairyMoving:
20758 82 itemsbuf[i].misc1 = moving_fairy_hearts;
20759 82 itemsbuf[i].misc2 = moving_fairy_magic;
20760 82 itemsbuf[i].misc3 = 50;
20761
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if (moving_fairy_heart_percent) itemsbuf[i].flags |= item_flag1;
20762
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if (moving_fairy_magic_percent) itemsbuf[i].flags |= item_flag2;
20763 82 break;
20764
20765 case iRPotion:
20766 82 itemsbuf[i].misc1 = red_potion_hearts;
20767 82 itemsbuf[i].misc2 = red_potion_magic;
20768
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if (red_potion_heart_percent) itemsbuf[i].flags |= item_flag1;
20769
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if (red_potion_magic_percent) itemsbuf[i].flags |= item_flag2;
20770 82 break;
20771
20772 case iBPotion:
20773 82 itemsbuf[i].misc1 = blue_potion_hearts;
20774 82 itemsbuf[i].misc2 = blue_potion_magic;
20775
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if (blue_potion_heart_percent) itemsbuf[i].flags |= item_flag1;
20776
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if (blue_potion_magic_percent) itemsbuf[i].flags |= item_flag2;
20777 82 break;
20778
20779 case iSword:
20780 82 itemsbuf[i].pickup_hearts = sword_hearts[0];
20781 82 itemsbuf[i].misc1 = beam_hearts[0];
20782 82 itemsbuf[i].misc2 = beam_power[0];
20783 // It seems that item_flag1 was already added by reset_itembuf()...
20784 82 itemsbuf[i].flags &= (!get_bit(&beam_percent,0)) ? ~item_flag1 : ~item_none;
20785 82 break;
20786
20787 case iWSword:
20788 82 itemsbuf[i].pickup_hearts = sword_hearts[1];
20789 82 itemsbuf[i].misc1 = beam_hearts[1];
20790 82 itemsbuf[i].misc2 = beam_power[1];
20791 82 itemsbuf[i].flags &= (!get_bit(&beam_percent,1)) ? ~item_flag1 : ~item_none;
20792 82 break;
20793
20794 case iMSword:
20795 82 itemsbuf[i].pickup_hearts = sword_hearts[2];
20796 82 itemsbuf[i].misc1 = beam_hearts[2];
20797 82 itemsbuf[i].misc2 = beam_power[2];
20798 82 itemsbuf[i].flags &= (!get_bit(&beam_percent,2)) ? ~item_flag1 : ~item_none;
20799 82 break;
20800
20801 case iXSword:
20802 82 itemsbuf[i].pickup_hearts = sword_hearts[3];
20803 82 itemsbuf[i].misc1 = beam_hearts[3];
20804 82 itemsbuf[i].misc2 = beam_power[3];
20805 82 itemsbuf[i].flags &= (!get_bit(&beam_percent,3)) ? ~item_flag1 : ~item_none;
20806 82 break;
20807
20808 case iHookshot:
20809 82 itemsbuf[i].misc1 = hookshot_length;
20810 82 itemsbuf[i].misc2 = hookshot_links;
20811 82 break;
20812
20813 case iLongshot:
20814 82 itemsbuf[i].misc1 = longshot_length;
20815 82 itemsbuf[i].misc2 = longshot_links;
20816 82 break;
20817 }
20818 21074 }
20819
20820
6/6
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 282 times.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 1 times.
305 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<168)))
20821 {
20822 //was new subscreen rule
20823 22 subscr_mode=get_qr(qr_FREEFORM)?1:0;
20824 22 set_qr(qr_FREEFORM,0);
20825 22 }
20826
20827
5/6
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 282 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
305 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<185)))
20828 {
20829 23 temp_zinit.start_dmap=0;
20830 23 }
20831
20832
5/6
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 282 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
305 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<186)))
20833 {
20834 23 temp_zinit.heroAnimationStyle=get_qr(qr_BSZELDA)?1:0;
20835 23 }
20836
20837
3/4
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 223 times.
✓ Branch 2 taken 82 times.
✗ Branch 3 not taken.
305 if(s_version < 16 && get_bit(deprecated_rules, qr_COOLSCROLL+1))
20838 {
20839 //addOldStyleFamily(&temp_zinit, itemsbuf, itype_wallet, 4); //is this needed?
20840 temp_zinit.mcounter[crMONEY]=999;
20841 //temp_zinit.counter[crMONEY]=999; //This rule only gave you an invisible max wallet; it did not give you max rupies.
20842 }
20843
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 6 times.
305 if(Header->zelda_version < 0x190) //1.84 bugfix. -Z
20844 {
20845 //temp_zinit.items[iBombBag] = true; //No, this is 30 max bombs!
20846 6 temp_zinit.mcounter[crBOMBS] = 8;
20847 6 }
20848 // al_trace("About to copy over new init data values for quest made in: %x\n", Header->zelda_version);
20849 //time to ensure that we port all new values properly:
20850
2/2
✓ Branch 0 taken 223 times.
✓ Branch 1 taken 82 times.
305 if(Header->zelda_version < 0x250)
20851 {
20852
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 temp_zinit.mcounter[crSBOMBS] = bomb_ratio > 0 ? ( temp_zinit.mcounter[crBOMBS]/temp_zinit.bomb_ratio ) : (temp_zinit.mcounter[crBOMBS]/4);
20853 82 }
20854
20855
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 288 times.
305 if(s_version > 21)
20856 {
20857
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.hp_per_heart,f))
20858 {
20859 return qe_invalid;
20860 }
20861
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.magic_per_block,f))
20862 {
20863 return qe_invalid;
20864 }
20865
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.hero_damage_multiplier,f))
20866 {
20867 return qe_invalid;
20868 }
20869
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.ene_damage_multiplier,f))
20870 {
20871 return qe_invalid;
20872 }
20873 17 }
20874 else
20875 {
20876 288 temp_zinit.hp_per_heart = 16; //HP_PER_HEART, previously hardcoded
20877 288 temp_zinit.magic_per_block = 32; //MAGICPERBLOCK, previously hardcoded
20878 288 temp_zinit.hero_damage_multiplier = 2; //DAMAGE_MULTIPLIER, previously hardcoded
20879 288 temp_zinit.ene_damage_multiplier = 4; //(HP_PER_HEART/4), previously hardcoded
20880 }
20881
20882
2/2
✓ Branch 0 taken 288 times.
✓ Branch 1 taken 17 times.
305 if(s_version > 22)
20883 {
20884
2/2
✓ Branch 0 taken 425 times.
✓ Branch 1 taken 17 times.
442 for(int32_t q = crCUSTOM1; q <= crCUSTOM25; ++q)
20885
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 425 times.
425 if(!p_igetw(&temp_zinit.counter[q],f))
20886 return qe_invalid;
20887
2/2
✓ Branch 0 taken 425 times.
✓ Branch 1 taken 17 times.
442 for(int32_t q = crCUSTOM1; q <= crCUSTOM25; ++q)
20888
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 425 times.
425 if(!p_igetw(&temp_zinit.mcounter[q],f))
20889 return qe_invalid;
20890 17 }
20891
20892
20893
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 288 times.
305 if(s_version > 23)
20894 {
20895
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.dither_type,f))
20896 {
20897 return qe_invalid;
20898 }
20899
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.dither_arg,f))
20900 {
20901 return qe_invalid;
20902 }
20903
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.dither_percent,f))
20904 {
20905 return qe_invalid;
20906 }
20907
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.def_lightrad,f))
20908 {
20909 return qe_invalid;
20910 }
20911
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.transdark_percent,f))
20912 {
20913 return qe_invalid;
20914 }
20915 17 }
20916 else
20917 {
20918 288 temp_zinit.dither_type = 0;
20919 288 temp_zinit.dither_arg = 0;
20920 288 temp_zinit.dither_percent = 20;
20921 288 temp_zinit.def_lightrad = 24;
20922 288 temp_zinit.transdark_percent = 0;
20923 }
20924
20925
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 288 times.
305 if(s_version > 24)
20926 {
20927
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.darkcol,f))
20928 {
20929 return qe_invalid;
20930 }
20931 17 }
20932 else
20933 {
20934 288 temp_zinit.darkcol = BLACK;
20935 }
20936
20937
2/2
✓ Branch 0 taken 288 times.
✓ Branch 1 taken 17 times.
305 if(s_version > 25)
20938 {
20939
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetl(&temp_zinit.gravity,f))
20940 {
20941 return qe_invalid;
20942 }
20943
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetl(&temp_zinit.swimgravity,f))
20944 {
20945 return qe_invalid;
20946 }
20947 17 }
20948
20949
20950
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 288 times.
305 if(s_version > 26)
20951 {
20952
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.heroSideswimUpStep,f))
20953 {
20954 return qe_invalid;
20955 }
20956
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.heroSideswimSideStep,f))
20957 {
20958 return qe_invalid;
20959 }
20960
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.heroSideswimDownStep,f))
20961 {
20962 return qe_invalid;
20963 }
20964 17 }
20965 else
20966 {
20967 288 temp_zinit.heroSideswimUpStep = 150;
20968 288 temp_zinit.heroSideswimSideStep = 100;
20969 288 temp_zinit.heroSideswimDownStep = 75;
20970 }
20971
20972
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 288 times.
305 if(s_version > 27)
20973 {
20974
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetl(&temp_zinit.exitWaterJump,f))
20975 {
20976 return qe_invalid;
20977 }
20978 17 }
20979 else
20980 {
20981 288 temp_zinit.exitWaterJump = 0;
20982 }
20983
20984
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 288 times.
305 if(s_version > 29)
20985 {
20986
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetl(&temp_zinit.bunny_ltm,f))
20987 {
20988 return qe_invalid;
20989 }
20990 17 }
20991 else
20992 {
20993 288 temp_zinit.bunny_ltm = 0;
20994 }
20995
20996
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 288 times.
305 if(s_version > 30)
20997 {
20998
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.switchhookstyle,f))
20999 {
21000 return qe_invalid;
21001 }
21002 17 }
21003 else
21004 {
21005 288 temp_zinit.switchhookstyle = 1;
21006 }
21007
21008
2/2
✓ Branch 0 taken 288 times.
✓ Branch 1 taken 17 times.
305 if(s_version > 31)
21009 {
21010
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.magicdrainrate,f))
21011 {
21012 return qe_invalid;
21013 }
21014 17 }
21015
21016 305 temp_zinit.clear_genscript();
21017
2/2
✓ Branch 0 taken 293 times.
✓ Branch 1 taken 12 times.
305 if(s_version > 32)
21018 {
21019 12 word numgenscript = 0;
21020
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetw(&numgenscript,f))
21021 return qe_invalid;
21022
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if (numgenscript > NUMSCRIPTSGENERIC)
21023 return qe_invalid;
21024
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 for(auto q = 1; q < numgenscript; ++q)
21025 {
21026 if(!p_getc(&tempbyte,f))
21027 return qe_invalid;
21028 if(!(tempbyte&2))
21029 continue;
21030 temp_zinit.gen_doscript.set(q, tempbyte&1);
21031 if(!p_igetw(&temp_zinit.gen_exitState[q],f))
21032 return qe_invalid;
21033 if(!p_igetw(&temp_zinit.gen_reloadState[q],f))
21034 return qe_invalid;
21035 for(auto p = 0; p < 8; ++p)
21036 if(!p_igetl(&temp_zinit.gen_initd[q][p],f))
21037 return qe_invalid;
21038 dword sz;
21039 if(!p_igetl(&sz,f))
21040 return qe_invalid;
21041 temp_zinit.gen_data[q].resize(sz);
21042 std::vector<int32_t> dummy;
21043 if(!p_getlvec(&dummy,f))
21044 return qe_invalid;
21045 temp_zinit.gen_data[q] = dummy;
21046 if(!p_igetl(&temp_zinit.gen_eventstate[q],f))
21047 return qe_invalid;
21048 }
21049 12 }
21050
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 6 times.
305 if(s_version > 33)
21051 {
21052
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(!p_getc(&temp_zinit.hero_swim_mult,f))
21053 return qe_invalid;
21054
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(!p_getc(&temp_zinit.hero_swim_div,f))
21055 return qe_invalid;
21056 6 }
21057
1/2
✓ Branch 0 taken 305 times.
✗ Branch 1 not taken.
305 if(s_version > 34)
21058 {
21059 uint32_t num_used_mapscr_data;
21060 if(!p_igetl(&num_used_mapscr_data,f))
21061 return qe_invalid;
21062 for(uint32_t q = 0; q < num_used_mapscr_data; ++q)
21063 {
21064 uint32_t sz;
21065 if(!p_igetl(&sz,f))
21066 return qe_invalid;
21067 temp_zinit.screen_data[q].resize(sz);
21068 if(sz)
21069 {
21070 std::vector<int32_t> dummy;
21071 if(!p_getlvec(&dummy,f))
21072 return qe_invalid;
21073 temp_zinit.screen_data[q] = dummy;
21074 }
21075 }
21076 }
21077
1/2
✓ Branch 0 taken 305 times.
✗ Branch 1 not taken.
305 if (s_version > 35)
21078 if(!p_igetzf(&temp_zinit.shove_offset,f))
21079 return qe_invalid;
21080
21081 305 temp_zinit.counter[crLIFE] *= temp_zinit.hp_per_heart;
21082 305 temp_zinit.mcounter[crLIFE] *= temp_zinit.hp_per_heart;
21083
2/2
✓ Branch 0 taken 194 times.
✓ Branch 1 taken 111 times.
305 if(!temp_zinit.flags.get(INIT_FL_CONTPERCENT))
21084 111 temp_zinit.cont_heart *= temp_zinit.hp_per_heart;
21085
21086 305 return 0;
21087 305 }
21088 480 int32_t readinitdata(PACKFILE *f, zquestheader *Header)
21089 {
21090 480 zinitdata temp_zinit = {};
21091
21092
3/4
✓ Branch 0 taken 457 times.
✓ Branch 1 taken 23 times.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
480 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_initdata);
21093
21094 int32_t dummy;
21095 480 word s_version=0;
21096 byte padding;
21097
21098
2/2
✓ Branch 0 taken 457 times.
✓ Branch 1 taken 23 times.
480 if(Header->zelda_version > 0x192)
21099 {
21100
2/4
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 457 times.
✗ Branch 3 not taken.
457 if(!p_igetw(&s_version,f))
21101 return qe_invalid;
21102 457 FFCore.quest_format[vInitData] = s_version;
21103
21104
2/4
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 457 times.
✗ Branch 3 not taken.
457 if(!read_deprecated_section_cversion(f))
21105 return qe_invalid;
21106
21107 //section size
21108
2/4
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 457 times.
✗ Branch 3 not taken.
457 if(!p_igetl(&dummy,f))
21109 return qe_invalid;
21110 457 }
21111
21112
2/2
✓ Branch 0 taken 305 times.
✓ Branch 1 taken 175 times.
480 if(s_version < 37)
21113 {
21114
2/4
✓ Branch 0 taken 305 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 305 times.
305 if(auto ret = readinitdata_old(f,Header,s_version,temp_zinit))
21115 return ret;
21116 305 }
21117 else
21118 {
21119 175 subscr_mode = ssdtMAX;
21120
2/2
✓ Branch 0 taken 5600 times.
✓ Branch 1 taken 175 times.
5775 for(int q = 0; q < MAXITEMS/8; ++q)
21121
2/4
✓ Branch 0 taken 5600 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5600 times.
5600 if(!p_getc(&temp_zinit.items[q], f))
21122 return qe_invalid;
21123
2/2
✓ Branch 0 taken 129 times.
✓ Branch 1 taken 46 times.
175 if(s_version >= 42)
21124 {
21125
2/2
✓ Branch 0 taken 66048 times.
✓ Branch 1 taken 129 times.
66177 for(int q = 0; q < MAXLEVELS; ++q)
21126 {
21127
2/4
✓ Branch 0 taken 66048 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 66048 times.
66048 if(!p_getc(&temp_zinit.litems[q], f))
21128 return qe_invalid;
21129 66048 }
21130 129 }
21131 else
21132 {
21133 byte tmp_map[MAXLEVELS/8];
21134 byte tmp_compass[MAXLEVELS/8];
21135 byte tmp_boss_key[MAXLEVELS/8];
21136 byte tmp_mcguffin[MAXLEVELS/8];
21137
2/2
✓ Branch 0 taken 2944 times.
✓ Branch 1 taken 46 times.
2990 for(int q = 0; q < MAXLEVELS/8; ++q)
21138 {
21139
2/4
✓ Branch 0 taken 2944 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2944 times.
✗ Branch 3 not taken.
2944 if(!p_getc(&tmp_map[q], f))
21140 return qe_invalid;
21141
2/4
✓ Branch 0 taken 2944 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2944 times.
2944 if(!p_getc(&tmp_compass[q], f))
21142 return qe_invalid;
21143
2/4
✓ Branch 0 taken 2944 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2944 times.
2944 if(!p_getc(&tmp_boss_key[q], f))
21144 return qe_invalid;
21145
2/4
✓ Branch 0 taken 2944 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2944 times.
✗ Branch 3 not taken.
2944 if(!p_getc(&tmp_mcguffin[q], f))
21146 return qe_invalid;
21147 2944 }
21148
2/2
✓ Branch 0 taken 23552 times.
✓ Branch 1 taken 46 times.
23598 for(int q = 0; q < MAXLEVELS; ++q)
21149 {
21150
2/4
✓ Branch 0 taken 23552 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 23552 times.
23552 SETFLAG(temp_zinit.litems[q], liMAP, get_bit(tmp_map, q));
21151
3/4
✓ Branch 0 taken 23552 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20 times.
✓ Branch 3 taken 23532 times.
23552 SETFLAG(temp_zinit.litems[q], liCOMPASS, get_bit(tmp_compass, q));
21152
2/4
✓ Branch 0 taken 23552 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 23552 times.
23552 SETFLAG(temp_zinit.litems[q], liBOSSKEY, get_bit(tmp_boss_key, q));
21153
3/4
✓ Branch 0 taken 23552 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 144 times.
✓ Branch 3 taken 23408 times.
23552 SETFLAG(temp_zinit.litems[q], liTRIFORCE, get_bit(tmp_mcguffin, q));
21154 23552 }
21155 }
21156
2/4
✓ Branch 0 taken 175 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 175 times.
✗ Branch 3 not taken.
175 if(!p_getbvec(&temp_zinit.level_keys, f))
21157 return qe_invalid;
21158 byte num_counters;
21159
2/4
✓ Branch 0 taken 175 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 175 times.
✗ Branch 3 not taken.
175 if(!p_getc(&num_counters,f))
21160 return qe_invalid;
21161
2/2
✓ Branch 0 taken 18725 times.
✓ Branch 1 taken 175 times.
18900 for(int q = 0; q < num_counters; ++q)
21162
2/4
✓ Branch 0 taken 18725 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 18725 times.
18725 if(!p_igetw(&temp_zinit.counter[q],f))
21163 return qe_invalid;
21164
2/2
✓ Branch 0 taken 175 times.
✓ Branch 1 taken 18725 times.
18900 for(int q = 0; q < num_counters; ++q)
21165
2/4
✓ Branch 0 taken 18725 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 18725 times.
18725 if(!p_igetw(&temp_zinit.mcounter[q],f))
21166 return qe_invalid;
21167
2/4
✓ Branch 0 taken 175 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 175 times.
✗ Branch 3 not taken.
175 if(!p_getc(&temp_zinit.bomb_ratio,f))
21168 return qe_invalid;
21169
2/4
✓ Branch 0 taken 175 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 175 times.
✗ Branch 3 not taken.
175 if(!p_getc(&temp_zinit.hcp,f))
21170 return qe_invalid;
21171
2/4
✓ Branch 0 taken 175 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 175 times.
✗ Branch 3 not taken.
175 if(!p_getc(&temp_zinit.hcp_per_hc,f))
21172 return qe_invalid;
21173
2/4
✓ Branch 0 taken 175 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 175 times.
✗ Branch 3 not taken.
175 if(!p_igetw(&temp_zinit.cont_heart,f))
21174 return qe_invalid;
21175
2/4
✓ Branch 0 taken 175 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 175 times.
✗ Branch 3 not taken.
175 if(!p_getc(&temp_zinit.hp_per_heart,f))
21176 return qe_invalid;
21177
2/4
✓ Branch 0 taken 175 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 175 times.
✗ Branch 3 not taken.
175 if(!p_getc(&temp_zinit.magic_per_block,f))
21178 return qe_invalid;
21179
2/4
✓ Branch 0 taken 175 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 175 times.
✗ Branch 3 not taken.
175 if(!p_getc(&temp_zinit.hero_damage_multiplier,f))
21180 return qe_invalid;
21181
2/4
✓ Branch 0 taken 175 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 175 times.
✗ Branch 3 not taken.
175 if(!p_getc(&temp_zinit.ene_damage_multiplier,f))
21182 return qe_invalid;
21183
2/4
✓ Branch 0 taken 175 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 175 times.
✗ Branch 3 not taken.
175 if(!p_getc(&temp_zinit.dither_type,f))
21184 return qe_invalid;
21185
2/4
✓ Branch 0 taken 175 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 175 times.
✗ Branch 3 not taken.
175 if(!p_getc(&temp_zinit.dither_arg,f))
21186 return qe_invalid;
21187
2/4
✓ Branch 0 taken 175 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 175 times.
✗ Branch 3 not taken.
175 if(!p_getc(&temp_zinit.dither_percent,f))
21188 return qe_invalid;
21189
2/4
✓ Branch 0 taken 175 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 175 times.
✗ Branch 3 not taken.
175 if(!p_getc(&temp_zinit.def_lightrad,f))
21190 return qe_invalid;
21191
2/4
✓ Branch 0 taken 175 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 175 times.
✗ Branch 3 not taken.
175 if(!p_getc(&temp_zinit.transdark_percent,f))
21192 return qe_invalid;
21193
2/4
✓ Branch 0 taken 175 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 175 times.
✗ Branch 3 not taken.
175 if(!p_getc(&temp_zinit.darkcol,f))
21194 return qe_invalid;
21195
2/4
✓ Branch 0 taken 175 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 175 times.
✗ Branch 3 not taken.
175 if(!p_igetl(&temp_zinit.ss_grid_x,f))
21196 return qe_invalid;
21197
2/4
✓ Branch 0 taken 175 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 175 times.
✗ Branch 3 not taken.
175 if(!p_igetl(&temp_zinit.ss_grid_y,f))
21198 return qe_invalid;
21199
2/4
✓ Branch 0 taken 175 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 175 times.
✗ Branch 3 not taken.
175 if(!p_igetl(&temp_zinit.ss_grid_xofs,f))
21200 return qe_invalid;
21201
2/4
✓ Branch 0 taken 175 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 175 times.
175 if(!p_igetl(&temp_zinit.ss_grid_yofs,f))
21202 return qe_invalid;
21203
2/4
✓ Branch 0 taken 175 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 175 times.
✗ Branch 3 not taken.
175 if(!p_igetl(&temp_zinit.ss_grid_color,f))
21204 return qe_invalid;
21205
2/4
✓ Branch 0 taken 175 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 175 times.
✗ Branch 3 not taken.
175 if(!p_igetl(&temp_zinit.ss_bbox_1_color,f))
21206 return qe_invalid;
21207
2/4
✓ Branch 0 taken 175 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 175 times.
✗ Branch 3 not taken.
175 if(!p_igetl(&temp_zinit.ss_bbox_2_color,f))
21208 return qe_invalid;
21209
2/4
✓ Branch 0 taken 175 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 175 times.
✗ Branch 3 not taken.
175 if(!p_igetl(&temp_zinit.ss_flags,f))
21210 return qe_invalid;
21211
2/4
✓ Branch 0 taken 175 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 175 times.
✗ Branch 3 not taken.
175 if(!p_getbitstr(&temp_zinit.flags,f))
21212 return qe_invalid;
21213
2/4
✓ Branch 0 taken 175 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 175 times.
✗ Branch 3 not taken.
175 if(!p_getc(&temp_zinit.last_map,f))
21214 return qe_invalid;
21215
2/4
✓ Branch 0 taken 175 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 175 times.
✗ Branch 3 not taken.
175 if(!p_getc(&temp_zinit.last_screen,f))
21216 return qe_invalid;
21217
2/4
✓ Branch 0 taken 175 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 175 times.
✗ Branch 3 not taken.
175 if(!p_getc(&temp_zinit.msg_more_x,f))
21218 return qe_invalid;
21219
2/4
✓ Branch 0 taken 175 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 175 times.
✗ Branch 3 not taken.
175 if(!p_getc(&temp_zinit.msg_more_y,f))
21220 return qe_invalid;
21221
2/4
✓ Branch 0 taken 175 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 175 times.
✗ Branch 3 not taken.
175 if(!p_getc(&temp_zinit.msg_more_is_offset,f))
21222 return qe_invalid;
21223
2/4
✓ Branch 0 taken 175 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 175 times.
✗ Branch 3 not taken.
175 if(!p_getc(&temp_zinit.msg_speed,f))
21224 return qe_invalid;
21225
2/4
✓ Branch 0 taken 175 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 175 times.
✗ Branch 3 not taken.
175 if(!p_igetl(&temp_zinit.gravity,f))
21226 return qe_invalid;
21227
2/4
✓ Branch 0 taken 175 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 175 times.
✗ Branch 3 not taken.
175 if(!p_igetl(&temp_zinit.swimgravity,f))
21228 return qe_invalid;
21229
2/4
✓ Branch 0 taken 175 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 175 times.
✗ Branch 3 not taken.
175 if(!p_igetw(&temp_zinit.terminalv,f))
21230 return qe_invalid;
21231
2/4
✓ Branch 0 taken 175 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 175 times.
✗ Branch 3 not taken.
175 if(!p_getc(&temp_zinit.hero_swim_speed,f))
21232 return qe_invalid;
21233
2/4
✓ Branch 0 taken 175 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 175 times.
✗ Branch 3 not taken.
175 if(!p_getc(&temp_zinit.hero_swim_mult,f))
21234 return qe_invalid;
21235
2/4
✓ Branch 0 taken 175 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 175 times.
✗ Branch 3 not taken.
175 if(!p_getc(&temp_zinit.hero_swim_div,f))
21236 return qe_invalid;
21237
2/4
✓ Branch 0 taken 175 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 175 times.
✗ Branch 3 not taken.
175 if(!p_igetw(&temp_zinit.heroSideswimUpStep,f))
21238 return qe_invalid;
21239
2/4
✓ Branch 0 taken 175 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 175 times.
✗ Branch 3 not taken.
175 if(!p_igetw(&temp_zinit.heroSideswimSideStep,f))
21240 return qe_invalid;
21241
2/4
✓ Branch 0 taken 175 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 175 times.
✗ Branch 3 not taken.
175 if(!p_igetw(&temp_zinit.heroSideswimDownStep,f))
21242 return qe_invalid;
21243
2/4
✓ Branch 0 taken 175 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 175 times.
✗ Branch 3 not taken.
175 if(!p_igetl(&temp_zinit.exitWaterJump,f))
21244 return qe_invalid;
21245
2/4
✓ Branch 0 taken 175 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 175 times.
✗ Branch 3 not taken.
175 if(!p_igetw(&temp_zinit.heroStep,f))
21246 return qe_invalid;
21247
2/4
✓ Branch 0 taken 175 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 175 times.
✗ Branch 3 not taken.
175 if(!p_getc(&temp_zinit.heroAnimationStyle,f))
21248 return qe_invalid;
21249
2/4
✓ Branch 0 taken 175 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 175 times.
✗ Branch 3 not taken.
175 if(!p_getc(&temp_zinit.jump_hero_layer_threshold,f))
21250 return qe_invalid;
21251
2/4
✓ Branch 0 taken 175 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 175 times.
✗ Branch 3 not taken.
175 if(!p_igetl(&temp_zinit.bunny_ltm,f))
21252 return qe_invalid;
21253
2/4
✓ Branch 0 taken 175 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 175 times.
✗ Branch 3 not taken.
175 if(!p_igetw(&temp_zinit.start_dmap,f))
21254 return qe_invalid;
21255
2/4
✓ Branch 0 taken 175 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 175 times.
✗ Branch 3 not taken.
175 if(!p_igetw(&temp_zinit.subscrSpeed,f))
21256 return qe_invalid;
21257
2/4
✓ Branch 0 taken 175 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 175 times.
✗ Branch 3 not taken.
175 if(!p_getc(&temp_zinit.switchhookstyle,f))
21258 return qe_invalid;
21259
2/4
✓ Branch 0 taken 175 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 175 times.
✗ Branch 3 not taken.
175 if(!p_getc(&temp_zinit.magicdrainrate,f))
21260 return qe_invalid;
21261
2/4
✓ Branch 0 taken 175 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 175 times.
✗ Branch 3 not taken.
175 if(!p_igetzf(&temp_zinit.shove_offset,f))
21262 return qe_invalid;
21263
2/4
✓ Branch 0 taken 175 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 175 times.
✗ Branch 3 not taken.
175 if(!p_getbitstr(&temp_zinit.gen_doscript, f))
21264 return qe_invalid;
21265
2/4
✓ Branch 0 taken 175 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 175 times.
✗ Branch 3 not taken.
175 if(!p_getbmap(&temp_zinit.gen_exitState, f))
21266 return qe_invalid;
21267
2/4
✓ Branch 0 taken 175 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 175 times.
✗ Branch 3 not taken.
175 if(!p_getbmap(&temp_zinit.gen_reloadState, f))
21268 return qe_invalid;
21269
2/4
✓ Branch 0 taken 175 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 175 times.
175 if(!p_getbmap(&temp_zinit.gen_initd, f))
21270 return qe_invalid;
21271
2/4
✓ Branch 0 taken 175 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 175 times.
✗ Branch 3 not taken.
175 if(!p_getbmap(&temp_zinit.gen_eventstate, f))
21272 return qe_invalid;
21273
2/4
✓ Branch 0 taken 175 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 175 times.
✗ Branch 3 not taken.
175 if(!p_getbmap(&temp_zinit.gen_data, f))
21274 return qe_invalid;
21275
2/4
✓ Branch 0 taken 175 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 175 times.
✗ Branch 3 not taken.
175 if(!p_getbmap(&temp_zinit.screen_data, f))
21276 return qe_invalid;
21277
1/2
✓ Branch 0 taken 175 times.
✗ Branch 1 not taken.
175 if (s_version >= 38)
21278 {
21279
2/4
✓ Branch 0 taken 175 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 175 times.
✗ Branch 3 not taken.
175 if (!p_getc(&temp_zinit.spriteflickerspeed, f))
21280 return qe_invalid;
21281
2/4
✓ Branch 0 taken 175 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 175 times.
✗ Branch 3 not taken.
175 if (!p_getc(&temp_zinit.spriteflickercolor, f))
21282 return qe_invalid;
21283
2/4
✓ Branch 0 taken 175 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 175 times.
✗ Branch 3 not taken.
175 if (!p_getc(&temp_zinit.spriteflickertransp, f))
21284 return qe_invalid;
21285 175 }
21286
2/2
✓ Branch 0 taken 147 times.
✓ Branch 1 taken 28 times.
175 if(s_version >= 39)
21287
2/4
✓ Branch 0 taken 147 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 147 times.
✗ Branch 3 not taken.
147 if(!p_igetzf(&temp_zinit.air_drag, f))
21288 return qe_invalid;
21289
21290 // TODO: this first branch can likely be removed, as it only fixes an issues
21291 // that existed for a handful of temporary z3 builds (and active users of that
21292 // fork would have been updating often, beyond s_version 40).
21293
3/4
✓ Branch 0 taken 147 times.
✓ Branch 1 taken 28 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 147 times.
175 if (Header->is_z3 && s_version == 40)
21294 {
21295 if(!p_getc(&temp_zinit.region_mapping, f))
21296 return qe_invalid;
21297 }
21298 else
21299 {
21300
2/2
✓ Branch 0 taken 147 times.
✓ Branch 1 taken 28 times.
175 if(s_version >= 40)
21301 {
21302
2/4
✓ Branch 0 taken 147 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 147 times.
✗ Branch 3 not taken.
147 if(!p_igetw(&temp_zinit.light_wave_rate, f))
21303 return qe_invalid;
21304
2/4
✓ Branch 0 taken 147 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 147 times.
✗ Branch 3 not taken.
147 if(!p_igetw(&temp_zinit.light_wave_size, f))
21305 return qe_invalid;
21306 147 }
21307
21308
2/2
✓ Branch 0 taken 147 times.
✓ Branch 1 taken 28 times.
175 if(s_version >= 41)
21309 {
21310
2/4
✓ Branch 0 taken 147 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 147 times.
✗ Branch 3 not taken.
147 if(!p_getc(&temp_zinit.region_mapping, f))
21311 return qe_invalid;
21312 147 }
21313 }
21314 }
21315
2/2
✓ Branch 0 taken 358 times.
✓ Branch 1 taken 122 times.
480 if(s_version >= 43)
21316
2/2
✓ Branch 0 taken 31232 times.
✓ Branch 1 taken 122 times.
31354 for(uint q = 0; q < NUM_BOTTLE_SLOTS; ++q)
21317
2/4
✓ Branch 0 taken 31232 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 31232 times.
31232 if (!p_getc(&temp_zinit.bottle_slot[q], f))
21318 122 return qe_invalid;
21319
1/2
✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
480 if (should_skip)
21320 return 0;
21321
21322
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 480 times.
480 if(loading_tileset_flags & TILESET_CLEARMAPS)
21323 {
21324 temp_zinit.last_map = 0;
21325 temp_zinit.last_screen = 0;
21326 temp_zinit.screen_data.clear();
21327 }
21328
1/2
✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
480 temp_zinit.normalize();
21329
1/2
✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
480 zinit = temp_zinit;
21330
21331
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 480 times.
480 if(zinit.heroAnimationStyle==las_zelda3slow)
21332 {
21333 hero_animation_speed=2;
21334 }
21335 else
21336 {
21337 480 hero_animation_speed=1;
21338 }
21339
21340 480 return 0;
21341 480 }
21342
21343 /*
21344 void setupitemdropsets()
21345 {
21346 for(int32_t i=0; i<isMAX; i++)
21347 {
21348 memcpy(&item_drop_sets[i], &default_item_drop_sets[i], sizeof(item_drop_object));
21349 }
21350 }
21351 */
21352
21353 421 int32_t readitemdropsets(PACKFILE *f, int32_t version)
21354 {
21355
2/2
✓ Branch 0 taken 398 times.
✓ Branch 1 taken 23 times.
421 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_itemdropsets);
21356
21357 dword dummy_dword;
21358 421 word item_drop_sets_to_read=0;
21359 item_drop_object tempitemdrop;
21360 421 word s_version=0;
21361
21362
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 421 times.
421 if (!should_skip)
21363
2/2
✓ Branch 0 taken 107776 times.
✓ Branch 1 taken 421 times.
108197 for(int32_t i=0; i<MAXITEMDROPSETS; i++)
21364 {
21365 107776 memset(&item_drop_sets[i], 0, sizeof(item_drop_object));
21366 108197 }
21367
21368
2/2
✓ Branch 0 taken 398 times.
✓ Branch 1 taken 23 times.
421 if(version > 0x192)
21369 {
21370 398 item_drop_sets_to_read=0;
21371
21372 //section version info
21373
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_igetw(&s_version,f))
21374 {
21375 return qe_invalid;
21376 }
21377
21378 398 FFCore.quest_format[vItemDropsets] = s_version;
21379
21380
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!read_deprecated_section_cversion(f))
21381 {
21382 return qe_invalid;
21383 }
21384
21385 //section size
21386
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_igetl(&dummy_dword,f))
21387 {
21388 return qe_invalid;
21389 }
21390
21391 //finally... section data
21392
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_igetw(&item_drop_sets_to_read,f))
21393 {
21394 return qe_invalid;
21395 }
21396
21397
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 if (item_drop_sets_to_read > MAXITEMDROPSETS)
21398 {
21399 return qe_invalid;
21400 }
21401 398 }
21402 else
21403 {
21404 23 init_item_drop_sets();
21405 }
21406
21407
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 398 times.
421 if(s_version>=1)
21408 {
21409
2/2
✓ Branch 0 taken 6016 times.
✓ Branch 1 taken 398 times.
6414 for(int32_t i=0; i<item_drop_sets_to_read; i++)
21410 {
21411
1/2
✓ Branch 0 taken 6016 times.
✗ Branch 1 not taken.
6016 if(!p_getstr(tempitemdrop.name,sizeof(tempitemdrop.name)-1,f))
21412 {
21413 return qe_invalid;
21414 }
21415
21416
2/2
✓ Branch 0 taken 60160 times.
✓ Branch 1 taken 6016 times.
66176 for(int32_t j=0; j<10; ++j)
21417 {
21418
1/2
✓ Branch 0 taken 60160 times.
✗ Branch 1 not taken.
60160 if(!p_igetw(&tempitemdrop.item[j],f))
21419 {
21420 return qe_invalid;
21421 }
21422 60160 }
21423
21424
2/2
✓ Branch 0 taken 66176 times.
✓ Branch 1 taken 6016 times.
72192 for(int32_t j=0; j<11; ++j)
21425 {
21426
1/2
✓ Branch 0 taken 66176 times.
✗ Branch 1 not taken.
66176 if(!p_igetw(&tempitemdrop.chance[j],f))
21427 {
21428 return qe_invalid;
21429 }
21430 66176 }
21431
21432 // Dec 2008: Addition of the 'Tall Grass' set, #12,
21433 // overrides the quest's set #12.
21434
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6016 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6016 if(s_version<2 && i==12)
21435 continue;
21436
21437 // Deprecated: qr_NOCLOCKS and qr_ALLOW10RUPEEDROPS
21438
1/4
✓ Branch 0 taken 6016 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6016 if(s_version<2) for(int32_t j=0; j<10; ++j)
21439 {
21440 int32_t it = tempitemdrop.item[j];
21441
21442 if((itemsbuf[it].family == itype_rupee
21443 && ((itemsbuf[it].amount)&0xFFF) == 10)
21444 && !get_bit(deprecated_rules, qr_ALLOW10RUPEEDROPS_DEP))
21445 {
21446 tempitemdrop.chance[j+1]=0;
21447 }
21448 else if(itemsbuf[it].family == itype_clock && get_bit(deprecated_rules, qr_NOCLOCKS_DEP))
21449 {
21450 tempitemdrop.chance[j+1]=0;
21451 }
21452
21453 // From Sept 2007 to Dec 2008, non-gameplay items were prohibited.
21454 if(itemsbuf[it].family == itype_misc)
21455 {
21456 // If a non-gameplay item was selected, then item drop was aborted.
21457 // Reflect this by increasing the 'Nothing' chance accordingly.
21458 tempitemdrop.chance[0]+=tempitemdrop.chance[j+1];
21459 tempitemdrop.chance[j+1]=0;
21460 }
21461 }
21462
21463
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6016 times.
6016 if (!should_skip)
21464 6016 memcpy(&item_drop_sets[i], &tempitemdrop, sizeof(item_drop_object));
21465 6016 }
21466 398 }
21467
21468 421 return 0;
21469 421 }
21470
21471 398 int32_t readfavorites(PACKFILE *f, int32_t)
21472 {
21473
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_favorites);
21474
21475 int32_t temp_num;
21476 dword dummy_dword;
21477 word num_favorite_combos;
21478 word num_favorite_combo_aliases;
21479 398 word s_version=0;
21480
21481 //section version info
21482
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_igetw(&s_version,f))
21483 {
21484 return qe_invalid;
21485 }
21486
21487
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 if (!should_skip)
21488 398 FFCore.quest_format[vFavourites] = s_version;
21489
21490
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!read_deprecated_section_cversion(f))
21491 {
21492 return qe_invalid;
21493 }
21494
21495 //section size
21496
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_igetl(&dummy_dword,f))
21497 {
21498 return qe_invalid;
21499 }
21500
21501 398 word per_row = FAVORITECOMBO_PER_ROW;
21502 398 word per_page = FAVORITECOMBO_PER_PAGE;
21503
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 181 times.
398 if(s_version >= 3)
21504
1/2
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
181 if(!p_igetw(&per_row,f))
21505 return qe_invalid;
21506
2/2
✓ Branch 0 taken 223 times.
✓ Branch 1 taken 175 times.
398 if(s_version >= 4)
21507
1/2
✓ Branch 0 taken 175 times.
✗ Branch 1 not taken.
175 if(!p_igetw(&per_page,f))
21508 return qe_invalid;
21509 //finally... section data
21510
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_igetw(&num_favorite_combos,f))
21511 {
21512 return qe_invalid;
21513 }
21514
21515 //Hack; port old favorite combos
21516
3/4
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 181 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 217 times.
398 if(s_version < 3 && num_favorite_combos == 100)
21517 217 per_row = 13;
21518
21519
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 if (!should_skip)
21520
2/2
✓ Branch 0 taken 501480 times.
✓ Branch 1 taken 398 times.
501878 for(int q = 0; q < MAXFAVORITECOMBOS; ++q)
21521 501878 favorite_combos[q] = -1;
21522 398 byte favtype = 0;
21523
2/2
✓ Branch 0 taken 28305 times.
✓ Branch 1 taken 398 times.
28703 for(int32_t i=0; i<num_favorite_combos; i++)
21524 {
21525
2/2
✓ Branch 0 taken 6599 times.
✓ Branch 1 taken 21706 times.
28305 if (s_version >= 4)
21526 {
21527
1/2
✓ Branch 0 taken 6599 times.
✗ Branch 1 not taken.
6599 if (!p_getc(&favtype, f))
21528 {
21529 return qe_invalid;
21530 }
21531 6599 }
21532 else
21533 21706 favtype = 0;
21534
1/2
✓ Branch 0 taken 28305 times.
✗ Branch 1 not taken.
28305 if(!p_igetl(&temp_num,f))
21535 {
21536 return qe_invalid;
21537 }
21538
21539
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28305 times.
28305 if (should_skip)
21540 continue;
21541
21542
2/2
✓ Branch 0 taken 6599 times.
✓ Branch 1 taken 21706 times.
28305 if(per_row == FAVORITECOMBO_PER_ROW)
21543 {
21544 6599 favorite_combos[i] = temp_num;
21545 6599 favorite_combo_modes[i] = favtype;
21546 6599 }
21547 else
21548 {
21549 21706 int new_i = (i%per_row) + (i/per_row)*FAVORITECOMBO_PER_ROW;
21550 21706 favorite_combos[new_i]=temp_num;
21551 21706 favorite_combo_modes[new_i] = favtype;
21552 }
21553 28305 }
21554
21555 // Discard the separate favorite aliases list from previous versions
21556
2/2
✓ Branch 0 taken 175 times.
✓ Branch 1 taken 223 times.
398 if(s_version<4)
21557 {
21558
1/2
✓ Branch 0 taken 223 times.
✗ Branch 1 not taken.
223 if (!p_igetw(&num_favorite_combo_aliases, f))
21559 {
21560 return qe_invalid;
21561 }
21562
21563
2/2
✓ Branch 0 taken 21700 times.
✓ Branch 1 taken 223 times.
21923 for (int32_t i = 0; i < num_favorite_combo_aliases; i++)
21564 {
21565
1/2
✓ Branch 0 taken 21700 times.
✗ Branch 1 not taken.
21700 if (!p_igetl(&temp_num, f))
21566 {
21567 return qe_invalid;
21568 }
21569 21700 }
21570 223 }
21571
21572 398 word max_combo_cols = 0;
21573 398 word max_mappages = 0;
21574
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 181 times.
398 if(s_version >= 2)
21575 {
21576
1/2
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
181 if(!p_igetw(&max_combo_cols,f))
21577 return qe_invalid;
21578 181 int32_t tmp = 0, tmp2 = 0, tmp3 = 0;
21579
2/2
✓ Branch 0 taken 724 times.
✓ Branch 1 taken 181 times.
905 for(int q = 0; q < max_combo_cols; ++q)
21580 {
21581
1/2
✓ Branch 0 taken 724 times.
✗ Branch 1 not taken.
724 if(!p_igetl(&tmp,f))
21582 return qe_invalid;
21583
1/2
✓ Branch 0 taken 724 times.
✗ Branch 1 not taken.
724 if(!p_igetl(&tmp2,f))
21584 return qe_invalid;
21585
1/2
✓ Branch 0 taken 724 times.
✗ Branch 1 not taken.
724 if(!p_igetl(&tmp3,f))
21586 return qe_invalid;
21587
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 724 times.
724 if(q < MAX_COMBO_COLS)
21588 {
21589 724 First[q] = tmp;
21590 724 combo_alistpos[q] = tmp2;
21591 724 combo_pool_listpos[q] = tmp3;
21592 724 }
21593 724 }
21594
21595
1/2
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
181 if(!p_igetw(&max_mappages,f))
21596 return qe_invalid;
21597
2/2
✓ Branch 0 taken 1629 times.
✓ Branch 1 taken 181 times.
1810 for(int q = 0; q < max_mappages; ++q)
21598 {
21599
1/2
✓ Branch 0 taken 1629 times.
✗ Branch 1 not taken.
1629 if(!p_igetl(&tmp,f))
21600 return qe_invalid;
21601
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1629 times.
1629 if(!p_igetl(&tmp2,f))
21602 return qe_invalid;
21603
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1629 times.
1629 if(q < MAX_MAPPAGE_BTNS)
21604 {
21605 1629 map_page[q].map = tmp;
21606 1629 map_page[q].screen = tmp2;
21607 1629 }
21608 1629 }
21609 181 }
21610
21611
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 if (should_skip)
21612 return 0;
21613
21614
2/2
✓ Branch 0 taken 868 times.
✓ Branch 1 taken 398 times.
1266 for(int q = max_combo_cols; q < MAX_COMBO_COLS; ++q)
21615 {
21616 868 First[q] = 0;
21617 868 combo_alistpos[q] = 0;
21618 868 combo_pool_listpos[q] = 0;
21619 868 }
21620
2/2
✓ Branch 0 taken 1953 times.
✓ Branch 1 taken 398 times.
2351 for(int q = max_mappages; q < MAX_MAPPAGE_BTNS; ++q)
21621 {
21622 1953 map_page[q].map = 0;
21623 1953 map_page[q].screen = 0;
21624 1953 }
21625
21626 398 return 0;
21627 398 }
21628
21629 /*
21630 switch (ret) {
21631 case 0:
21632 break;
21633
21634 case qe_invalid:
21635 goto invalid;
21636 break;
21637 default:
21638 pack_fclose(f);
21639 if(!oldquest)
21640 delete_file(tmpfilename);
21641 return ret;
21642 break;
21643 }
21644 */
21645
21646 const char *skip_text[skip_max]=
21647 {
21648 "skip_header", "skip_rules", "skip_strings", "skip_misc",
21649 "skip_tiles", "skip_combos", "skip_comboaliases", "skip_csets",
21650 "skip_maps", "skip_dmaps", "skip_doors", "skip_items",
21651 "skip_weapons", "skip_colors", "skip_icons", "skip_initdata",
21652 "skip_guys", "skip_herosprites", "skip_subscreens", "skip_ffscript",
21653 "skip_sfx", "skip_midis", "skip_cheats", "skip_itemdropsets",
21654 "skip_favorites"
21655 };
21656
21657
21658 void port250QuestRules(){
21659
21660 portCandleRules(); //Candle
21661 portBombRules();
21662
21663 }
21664
21665 void portCandleRules()
21666 {
21667 bool hurtshero = get_qr(qr_FIREPROOFHERO);
21668 //itemdata itemsbuf;
21669 for ( int32_t q = 0; q < MAXITEMS; q++ )
21670 {
21671 if ( itemsbuf[q].family == itype_candle )
21672 {
21673 if ( hurtshero ) itemsbuf[q].flags |= item_flag2;
21674 else itemsbuf[q].flags &= ~ item_flag2;
21675 }
21676 }
21677 }
21678
21679 void portBombRules()
21680 {
21681 bool hurtshero = get_qr(qr_OUCHBOMBS);
21682 //itemdata itemsbuf;
21683 for ( int32_t q = 0; q < MAXITEMS; q++ )
21684 {
21685 if ( itemsbuf[q].family == itype_bomb )
21686 {
21687 if ( hurtshero ) itemsbuf[q].flags |= item_flag2;
21688 else itemsbuf[q].flags &= ~ item_flag2;
21689 }
21690 }
21691 }
21692
21693 18597 static int section_id_to_enum(int id)
21694 {
21695
24/27
✗ Branch 0 not taken.
✓ Branch 1 taken 804 times.
✓ Branch 2 taken 804 times.
✓ Branch 3 taken 804 times.
✓ Branch 4 taken 804 times.
✓ Branch 5 taken 804 times.
✓ Branch 6 taken 721 times.
✓ Branch 7 taken 804 times.
✓ Branch 8 taken 804 times.
✓ Branch 9 taken 804 times.
✓ Branch 10 taken 804 times.
✓ Branch 11 taken 804 times.
✓ Branch 12 taken 804 times.
✓ Branch 13 taken 721 times.
✓ Branch 14 taken 721 times.
✓ Branch 15 taken 804 times.
✓ Branch 16 taken 804 times.
✓ Branch 17 taken 745 times.
✓ Branch 18 taken 721 times.
✓ Branch 19 taken 721 times.
✓ Branch 20 taken 721 times.
✓ Branch 21 taken 804 times.
✓ Branch 22 taken 804 times.
✓ Branch 23 taken 745 times.
✓ Branch 24 taken 721 times.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
18597 switch (id)
21696 {
21697 case ID_HEADER: return skip_header;
21698 804 case ID_RULES: return skip_rules;
21699 804 case ID_STRINGS: return skip_strings;
21700 804 case ID_MISC: return skip_misc;
21701 804 case ID_TILES: return skip_tiles;
21702 804 case ID_COMBOS: return skip_combos;
21703 721 case ID_COMBOALIASES: return skip_comboaliases;
21704 804 case ID_CSETS: return skip_csets;
21705 804 case ID_MAPS: return skip_maps;
21706 804 case ID_DMAPS: return skip_dmaps;
21707 804 case ID_DOORS: return skip_doors;
21708 804 case ID_ITEMS: return skip_items;
21709 804 case ID_WEAPONS: return skip_weapons;
21710 721 case ID_COLORS: return skip_colors;
21711 721 case ID_ICONS: return skip_icons;
21712 804 case ID_INITDATA: return skip_initdata;
21713 804 case ID_GUYS: return skip_guys;
21714 745 case ID_HEROSPRITES: return skip_herosprites;
21715 721 case ID_SUBSCREEN: return skip_subscreens;
21716 721 case ID_FFSCRIPT: return skip_ffscript;
21717 721 case ID_SFX: return skip_sfx;
21718 804 case ID_MIDIS: return skip_midis;
21719 804 case ID_CHEATS: return skip_cheats;
21720 745 case ID_ITEMDROPSETS: return skip_itemdropsets;
21721 721 case ID_FAVORITES: return skip_favorites;
21722 case ID_ZINFO: return skip_zinfo;
21723 }
21724
21725 return -1;
21726 18597 }
21727
21728 18189 static int maybe_skip_section(PACKFILE* f, dword& section_id, const byte* skip_flags)
21729 {
21730 18189 int section_enum = section_id_to_enum(section_id);
21731
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18189 times.
18189 bool skip = section_enum >= 0 && get_bit(skip_flags, section_enum);
21732
2/2
✓ Branch 0 taken 6783 times.
✓ Branch 1 taken 11406 times.
18189 if (skip)
21733 {
21734 word s_version;
21735
1/2
✓ Branch 0 taken 6783 times.
✗ Branch 1 not taken.
6783 if (!p_igetw(&s_version,f))
21736 {
21737 return qe_invalid;
21738 }
21739
21740
1/2
✓ Branch 0 taken 6783 times.
✗ Branch 1 not taken.
6783 if (!read_deprecated_section_cversion(f))
21741 {
21742 return qe_invalid;
21743 }
21744
21745
3/4
✓ Branch 0 taken 323 times.
✓ Branch 1 taken 6460 times.
✓ Branch 2 taken 323 times.
✗ Branch 3 not taken.
6783 if (section_id == ID_RULES && s_version > 16)
21746 {
21747 dword dummy;
21748 if (!p_igetl(&dummy,f))
21749 {
21750 return qe_invalid;
21751 }
21752 }
21753
21754
3/4
✓ Branch 0 taken 323 times.
✓ Branch 1 taken 6460 times.
✓ Branch 2 taken 323 times.
✗ Branch 3 not taken.
6783 if (section_id == ID_FFSCRIPT && s_version >= 18)
21755 {
21756 word dummy;
21757 if (!p_igetw(&dummy,f))
21758 {
21759 return qe_invalid;
21760 }
21761 }
21762
21763 dword section_length;
21764
1/2
✓ Branch 0 taken 6783 times.
✗ Branch 1 not taken.
6783 if (!p_igetl(&section_length,f))
21765 {
21766 return qe_invalid;
21767 }
21768
21769
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6783 times.
6783 if (pack_fseek(f, section_length))
21770 {
21771 return qe_invalid;
21772 }
21773
21774
2/2
✓ Branch 0 taken 323 times.
✓ Branch 1 taken 6460 times.
6783 if (!pack_feof(f))
21775 {
21776
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6460 times.
6460 if (!p_mgetl(&section_id,f))
21777 {
21778 return qe_invalid;
21779 }
21780 6460 }
21781
21782 6783 return qe_cancel;
21783 }
21784
21785 11406 return qe_OK;
21786 18189 }
21787
21788 // TODO: this was copied from zc/zasm_utils.cpp
21789 288 static void _zasm_for_every_script(std::function<void(zasm_script*)> fn)
21790 {
21791 extern std::vector<std::shared_ptr<zasm_script>> zasm_scripts;
21792
21793 288 std::vector<zasm_script*> scripts;
21794
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 scripts.reserve(zasm_scripts.size());
21795
2/2
✓ Branch 0 taken 288 times.
✓ Branch 1 taken 309307 times.
309595 for (auto& script : zasm_scripts)
21796
3/4
✓ Branch 0 taken 309307 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8690 times.
✓ Branch 3 taken 300617 times.
309307 if (script->valid())
21797
1/2
✓ Branch 0 taken 8690 times.
✗ Branch 1 not taken.
8690 scripts.push_back(script.get());
21798
21799
2/4
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 288 times.
288 std::for_each(scripts.begin(), scripts.end(), fn);
21800 288 }
21801
21802 480 static bool compat_qr_hide_bottom_pixels(const zquestheader& header)
21803 {
21804 // 2.55.9 or newer?
21805
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 332 times.
480 if (header.compareVer(2, 55, 9) >= 0)
21806 148 return false; // defer to whatever was set
21807
21808 // Replays created in 2.55 for quests prior to 2.55.9 should continue hiding the bottom pixels.
21809
12/18
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 282 times.
✓ Branch 2 taken 282 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 282 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 50 times.
✓ Branch 7 taken 282 times.
✓ Branch 8 taken 50 times.
✓ Branch 9 taken 282 times.
✓ Branch 10 taken 50 times.
✓ Branch 11 taken 282 times.
✓ Branch 12 taken 37 times.
✓ Branch 13 taken 295 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
332 if (replay_is_replaying() && replay_get_meta_str("zc_version_created").starts_with("2.55"))
21810 37 return true;
21811
21812 // Quests prior to 2.55.9 with a scripted subscreen?
21813
2/2
✓ Branch 0 taken 148996 times.
✓ Branch 1 taken 291 times.
149287 for (int i = 0; i < MAXDMAPS; i++)
21814 {
21815 148996 int script = DMaps[i].active_sub_script;
21816
4/6
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 148992 times.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4 times.
148996 if (script && dmapscripts[script] && dmapscripts[script]->valid())
21817 4 return true;
21818 148992 }
21819
21820 // Only a couple quests take any time (~7ms) on my intel mac to check all the ZASM... cache those.
21821
1/2
✓ Branch 0 taken 291 times.
✗ Branch 1 not taken.
291 std::string title = header.title;
21822
3/4
✓ Branch 0 taken 291 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 288 times.
291 if (title == "Yuurand: Tales of the Labyrinth")
21823 3 return true;
21824
21825 // Look for ZASM setting values of 167, 168, etc. This is a sign that the script may be drawing something
21826 // near the old "bottom" of the screen, or is attempting to fill the entire screen with a draw command.
21827 // In these cases, the compat rule must be flipped on. As of writing, 72 quests in the PZC database match
21828 // this query: https://gist.github.com/connorjclark/edd12f84c9aac0c924ed328d3f8efcfa
21829 288 bool found = false;
21830
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 288 times.
8978 _zasm_for_every_script([&](auto script){
21831
2/2
✓ Branch 0 taken 3034 times.
✓ Branch 1 taken 5656 times.
8690 if (found) return;
21832
21833
2/2
✓ Branch 0 taken 5624 times.
✓ Branch 1 taken 25105847 times.
25111471 for (const auto& instr : script->zasm)
21834 {
21835
4/4
✓ Branch 0 taken 21972023 times.
✓ Branch 1 taken 3133824 times.
✓ Branch 2 taken 363407 times.
✓ Branch 3 taken 21608616 times.
25105847 if (!(instr.command == SETV || instr.command == PUSHV)) continue;
21836
21837 3497231 int value = instr.arg2;
21838
9/10
✓ Branch 0 taken 3497228 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 3497224 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 3497200 times.
✓ Branch 5 taken 24 times.
✓ Branch 6 taken 3497200 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✓ Branch 9 taken 3497199 times.
3497231 if (value == 167000000 || value == 168000000 || value == 167870000 || value == 167910000 || value == 168130000)
21839 {
21840 32 found = true;
21841 32 break;
21842 }
21843 }
21844 8690 });
21845
21846 288 return found;
21847 480 }
21848
21849 static int32_t prev_quest_format[versiontypesLAST];
21850 static byte prev_quest_rules[QUESTRULES_NEW_SIZE];
21851 static byte prev_extra_rules[EXTRARULES_SIZE];
21852 static byte prev_midi_flags[MIDIFLAGS_SIZE];
21853 static word prev_map_count;
21854
21855 // When skipping any section, we are loading a qst file just to poke at a couple things.
21856 // We should not mutate important globals in that case.
21857 // We should also restore these globals when loading a qst fails.
21858 // Globals that are read by usecases of `skip_flags` will have to be restored manually by the caller
21859 // (see load_imagebuf).
21860 804 static void store_prev_qstload_global_state()
21861 {
21862 804 memcpy(prev_quest_rules, quest_rules, QUESTRULES_NEW_SIZE);
21863 804 memcpy(prev_extra_rules, extra_rules, EXTRARULES_SIZE);
21864 804 memcpy(prev_midi_flags, midi_flags, MIDIFLAGS_SIZE);
21865 804 memcpy(prev_quest_format, FFCore.quest_format, versiontypesLAST);
21866 804 prev_map_count = map_count;
21867 804 }
21868
21869 324 static void restore_prev_qstload_global_state()
21870 {
21871 324 memcpy(quest_rules, prev_quest_rules, QUESTRULES_NEW_SIZE);
21872 324 memcpy(extra_rules, prev_extra_rules, EXTRARULES_SIZE);
21873 324 unpack_qrs();
21874 324 memcpy(midi_flags, prev_midi_flags, MIDIFLAGS_SIZE);
21875 324 memcpy(FFCore.quest_format, prev_quest_format, versiontypesLAST);
21876 324 map_count = prev_map_count;
21877 324 }
21878
21879 //Internal function for loadquest wrapper
21880 // TODO: refactor to never mutate global state, to make loading partial qst files easier and less error prone. huge project.
21881 804 static int32_t _lq_int(const char *filename, zquestheader *Header, miscQdata *Misc, zctune *tunes, bool show_progress, byte *skip_flags, byte printmetadata)
21882 {
21883 804 DMapEditorLastMaptileUsed = 0;
21884 804 combosread=false;
21885 804 mapsread=false;
21886 804 fixffcs=false;
21887
21888 804 store_prev_qstload_global_state();
21889
21890 804 bool skipping_any = false;
21891
2/2
✓ Branch 0 taken 3216 times.
✓ Branch 1 taken 804 times.
4020 for (int i = 0; i < 4; i++)
21892 3216 skipping_any |= skip_flags[i] ? true : false;
21893
21894 804 bool do_clear_scripts = !get_bit(skip_flags,skip_ffscript);
21895
1/2
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
804 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
21896 {
21897 set_bit(skip_flags, skip_ffscript, 1);
21898 setZScriptVersion(V_FFSCRIPT);
21899 FFCore.quest_format[vFFScript] = V_FFSCRIPT;
21900 FFCore.quest_format[vLastCompile] = V_FFSCRIPT;
21901 do_clear_scripts = true;
21902 }
21903
1/2
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
804 if(loading_tileset_flags & TILESET_CLEARMAPS)
21904 {
21905 set_bit(skip_flags, skip_maps, 1);
21906 }
21907
21908 char tmpfilename[L_tmpnam];
21909 804 temp_name(tmpfilename);
21910 804 bool catchup=false;
21911 byte tempbyte;
21912
21913 // oldquest flag is set when an unencrypted qst file is suspected.
21914 804 bool oldquest = false;
21915 804 int32_t open_error=0;
21916 804 PACKFILE *f=open_quest_file(&open_error, filename, show_progress);
21917
21918
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 804 times.
804 if (!f)
21919 {
21920 ASSERT(open_error != 0);
21921 return open_error;
21922 }
21923
21924 804 memset(quest_rules, 0, QUESTRULES_NEW_SIZE);
21925 804 memset(extra_rules, 0, EXTRARULES_SIZE);
21926 804 unpack_qrs();
21927
21928
2/2
✓ Branch 0 taken 324 times.
✓ Branch 1 taken 480 times.
804 if (!get_bit(skip_flags, skip_maps))
21929 480 Regions = {};
21930
21931
2/2
✓ Branch 0 taken 324 times.
✓ Branch 1 taken 480 times.
804 if(do_clear_scripts)
21932 {
21933 480 zScript.clear();
21934 480 globalmap.clear();
21935 480 genericmap.clear();
21936 480 ffcmap.clear();
21937 480 itemmap.clear();
21938 480 npcmap.clear();
21939 480 ewpnmap.clear();
21940 480 lwpnmap.clear();
21941 480 playermap.clear();
21942 480 dmapmap.clear();
21943 480 screenmap.clear();
21944 480 itemspritemap.clear();
21945 480 comboscriptmap.clear();
21946 480 subscreenmap.clear();
21947
21948
2/2
✓ Branch 0 taken 245280 times.
✓ Branch 1 taken 480 times.
245760 for(int32_t i=0; i<NUMSCRIPTFFC-1; i++)
21949 {
21950 245280 ffcmap[i].clear();
21951 245280 }
21952
21953 480 globalmap[0].slotname = "Slot 1:";
21954 480 globalmap[0].scriptname = "~Init";
21955 480 globalmap[0].update();
21956
21957
2/2
✓ Branch 0 taken 3360 times.
✓ Branch 1 taken 480 times.
3840 for(int32_t i=1; i<NUMSCRIPTGLOBAL; i++)
21958 {
21959 3360 globalmap[i].clear();
21960 3360 }
21961
21962
2/2
✓ Branch 0 taken 122400 times.
✓ Branch 1 taken 480 times.
122880 for(int32_t i=0; i<NUMSCRIPTITEM-1; i++)
21963 {
21964 122400 itemmap[i].clear();
21965 122400 }
21966
21967 //new script types -- prevent carrying over to a quest that you load after reading them
21968 //e.g., a quest has an npc script, and you make a blank quest, that now believes that it has an npc script, too!
21969
2/2
✓ Branch 0 taken 122400 times.
✓ Branch 1 taken 480 times.
122880 for(int32_t i=0; i<NUMSCRIPTGUYS-1; i++)
21970 {
21971 122400 npcmap[i].clear();
21972 122400 }
21973
2/2
✓ Branch 0 taken 122400 times.
✓ Branch 1 taken 480 times.
122880 for(int32_t i=0; i<NUMSCRIPTWEAPONS-1; i++)
21974 {
21975 122400 lwpnmap[i].clear();
21976 122400 }
21977
2/2
✓ Branch 0 taken 122400 times.
✓ Branch 1 taken 480 times.
122880 for(int32_t i=0; i<NUMSCRIPTWEAPONS-1; i++)
21978 {
21979 122400 ewpnmap[i].clear();
21980 122400 }
21981
2/2
✓ Branch 0 taken 1920 times.
✓ Branch 1 taken 480 times.
2400 for(int32_t i=0; i<NUMSCRIPTHERO-1; i++)
21982 {
21983 1920 playermap[i].clear();
21984 1920 }
21985
2/2
✓ Branch 0 taken 122400 times.
✓ Branch 1 taken 480 times.
122880 for(int32_t i=0; i<NUMSCRIPTSDMAP-1; i++)
21986 {
21987 122400 dmapmap[i].clear();
21988 122400 }
21989
2/2
✓ Branch 0 taken 122400 times.
✓ Branch 1 taken 480 times.
122880 for(int32_t i=0; i<NUMSCRIPTSCREEN-1; i++)
21990 {
21991 122400 screenmap[i].clear();
21992 122400 }
21993
2/2
✓ Branch 0 taken 122400 times.
✓ Branch 1 taken 480 times.
122880 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE-1; i++)
21994 {
21995 122400 itemspritemap[i].clear();
21996 122400 }
21997
2/2
✓ Branch 0 taken 245280 times.
✓ Branch 1 taken 480 times.
245760 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA-1; i++)
21998 {
21999 245280 comboscriptmap[i].clear();
22000 245280 }
22001
2/2
✓ Branch 0 taken 245280 times.
✓ Branch 1 taken 480 times.
245760 for(int32_t i=0; i<NUMSCRIPTSGENERIC-1; i++)
22002 {
22003 245280 genericmap[i].clear();
22004 245280 }
22005
2/2
✓ Branch 0 taken 122400 times.
✓ Branch 1 taken 480 times.
122880 for(int32_t i=0; i<NUMSCRIPTSSUBSCREEN-1; i++)
22006 {
22007 122400 subscreenmap[i].clear();
22008 122400 }
22009
22010 480 reset_scripts();
22011 480 }
22012
22013 804 zquestheader tempheader{};
22014
1/2
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
804 tempheader.filename = filename;
22015
1/2
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
804 zinfo tempzi;
22016
1/2
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
804 tempzi.clear();
22017 804 load_tmp_zi = &tempzi;
22018
22019 char zinfofilename[2048];
22020
1/2
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
804 replace_extension(zinfofilename, filename, "zinfo", 2047);
22021 804 int32_t ret=0;
22022
22023 //header
22024
1/2
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
804 box_out("Reading Header...");
22025
1/2
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
804 ret=readheader(f, &tempheader, printmetadata);
22026
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 804 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
804 checkstatus(ret);
22027
1/2
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
804 box_out("okay.");
22028
1/2
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
804 box_eol();
22029
22030
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 612 times.
804 if(read_zinfo)
22031 {
22032
1/2
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
192 box_out("Reading ZInfo - ");
22033
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 189 times.
✓ Branch 2 taken 192 times.
✗ Branch 3 not taken.
192 box_out(read_ext_zinfo ? "External..." : "Internal...");
22034
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 189 times.
192 if(read_ext_zinfo)
22035 {
22036
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 PACKFILE *inf=pack_fopen_password(zinfofilename, F_READ, "");
22037
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 ret=readzinfo(inf, tempzi, tempheader);
22038
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if(inf) pack_fclose(inf);
22039
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
3 checkstatus(ret);
22040 3 }
22041 else
22042 {
22043
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 ret=readzinfo(f, tempzi, tempheader);
22044
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 189 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
189 checkstatus(ret);
22045 }
22046
1/2
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
192 box_out("okay.");
22047
1/2
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
192 box_eol();
22048 192 }
22049
22050
2/2
✓ Branch 0 taken 780 times.
✓ Branch 1 taken 24 times.
804 if(tempheader.zelda_version>=0x193)
22051 {
22052 dword section_id;
22053
22054 //section id
22055
2/4
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 780 times.
✗ Branch 3 not taken.
780 if(!p_mgetl(&section_id,f))
22056 {
22057 goto invalid;
22058 }
22059
22060 780 std::set<dword> seen_sections;
22061
22062
3/4
✓ Branch 0 taken 18969 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18189 times.
✓ Branch 3 taken 780 times.
18969 while(!pack_feof(f))
22063 {
22064
2/4
✓ Branch 0 taken 18189 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18189 times.
✗ Branch 3 not taken.
18189 if (seen_sections.contains(section_id))
22065 goto invalid;
22066
1/2
✓ Branch 0 taken 18189 times.
✗ Branch 1 not taken.
18189 seen_sections.insert(section_id);
22067
22068
3/4
✓ Branch 0 taken 18189 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11406 times.
✓ Branch 3 taken 6783 times.
18189 if (int retval = maybe_skip_section(f, section_id, skip_flags); retval != qe_OK)
22069 {
22070
1/2
✓ Branch 0 taken 6783 times.
✗ Branch 1 not taken.
6783 if (retval == qe_cancel)
22071 6783 continue;
22072 checkstatus(retval);
22073 }
22074
22075
24/25
✓ Branch 0 taken 457 times.
✓ Branch 1 taken 457 times.
✓ Branch 2 taken 780 times.
✓ Branch 3 taken 780 times.
✓ Branch 4 taken 457 times.
✓ Branch 5 taken 398 times.
✓ Branch 6 taken 780 times.
✓ Branch 7 taken 457 times.
✓ Branch 8 taken 457 times.
✓ Branch 9 taken 457 times.
✓ Branch 10 taken 457 times.
✓ Branch 11 taken 457 times.
✓ Branch 12 taken 398 times.
✓ Branch 13 taken 398 times.
✓ Branch 14 taken 457 times.
✓ Branch 15 taken 457 times.
✓ Branch 16 taken 398 times.
✓ Branch 17 taken 398 times.
✓ Branch 18 taken 398 times.
✓ Branch 19 taken 398 times.
✓ Branch 20 taken 457 times.
✓ Branch 21 taken 457 times.
✓ Branch 22 taken 398 times.
✓ Branch 23 taken 398 times.
✗ Branch 24 not taken.
11406 switch(section_id)
22076 {
22077 case ID_RULES:
22078
22079 //rules
22080
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
457 if(catchup)
22081 {
22082 box_out("found.");
22083 box_eol();
22084 catchup=false;
22085 }
22086
22087
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_out("Reading Rules...");
22088
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 ret=readrules(f, &tempheader);
22089
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
457 checkstatus(ret);
22090
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_out("okay.");
22091
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_eol();
22092 457 break;
22093
22094 case ID_STRINGS:
22095
22096 //strings
22097
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
457 if(catchup)
22098 {
22099 box_out("found.");
22100 box_eol();
22101 catchup=false;
22102 }
22103
22104
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_out("Reading Strings...");
22105
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 ret=readstrings(f, &tempheader);
22106
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
457 checkstatus(ret);
22107
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_out("okay.");
22108
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_eol();
22109 457 break;
22110
22111 case ID_MISC:
22112
22113 //misc data
22114
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 780 times.
780 if(catchup)
22115 {
22116 box_out("found.");
22117 box_eol();
22118 catchup=false;
22119 }
22120
22121
1/2
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
780 box_out("Reading Misc. Data...");
22122
1/2
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
780 ret=readmisc(f, &tempheader, Misc);
22123
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 780 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
780 checkstatus(ret);
22124
1/2
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
780 box_out("okay.");
22125
1/2
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
780 box_eol();
22126 780 break;
22127
22128 case ID_TILES:
22129
22130 //tiles
22131
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 780 times.
780 if(catchup)
22132 {
22133 box_out("found.");
22134 box_eol();
22135 catchup=false;
22136 }
22137
22138
1/2
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
780 box_out("Reading Tiles...");
22139
1/2
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
780 ret=readtiles(f, newtilebuf, &tempheader, tempheader.zelda_version, tempheader.build, 0, NEWMAXTILES, false);
22140
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 780 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
780 checkstatus(ret);
22141
1/2
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
780 box_out("okay.");
22142
1/2
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
780 box_eol();
22143 780 break;
22144
22145 case ID_COMBOS:
22146
22147 //combos
22148
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
457 if(catchup)
22149 {
22150 box_out("found.");
22151 box_eol();
22152 catchup=false;
22153 }
22154
22155
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_out("Reading Combos...");
22156
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 ret=readcombos(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXCOMBOS);
22157 457 combosread=true;
22158
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
457 checkstatus(ret);
22159
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_out("okay.");
22160
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_eol();
22161 457 break;
22162
22163 case ID_COMBOALIASES:
22164
22165 //combo aliases
22166
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 if(catchup)
22167 {
22168 box_out("found.");
22169 box_eol();
22170 catchup=false;
22171 }
22172
22173
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 box_out("Reading Combo Aliases...");
22174
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 ret=readcomboaliases(f, &tempheader, tempheader.zelda_version, tempheader.build);
22175
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
398 checkstatus(ret);
22176
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 box_out("okay.");
22177
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 box_eol();
22178 398 break;
22179
22180 case ID_CSETS:
22181
22182 //color data
22183
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 780 times.
780 if(catchup)
22184 {
22185 box_out("found.");
22186 box_eol();
22187 catchup=false;
22188 }
22189
22190
1/2
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
780 box_out("Reading Color Data...");
22191
1/2
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
780 ret=readcolordata(f, Misc, tempheader.zelda_version, tempheader.build, 0, newerpdTOTAL);
22192
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 780 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
780 checkstatus(ret);
22193
1/2
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
780 box_out("okay.");
22194
1/2
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
780 box_eol();
22195 780 break;
22196
22197 case ID_MAPS:
22198
22199 //maps
22200
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
457 if(catchup)
22201 {
22202 box_out("found.");
22203 box_eol();
22204 catchup=false;
22205 }
22206
22207
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_out("Reading Maps...");
22208
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 ret=readmaps(f, &tempheader);
22209 457 mapsread=true;
22210
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
457 checkstatus(ret);
22211
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_out("okay.");
22212
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_eol();
22213 457 break;
22214
22215 case ID_DMAPS:
22216
22217 //dmaps
22218
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
457 if(catchup)
22219 {
22220 box_out("found.");
22221 box_eol();
22222 catchup=false;
22223 }
22224
22225
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_out("Reading DMaps...");
22226
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 ret=readdmaps(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXDMAPS);
22227
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
457 checkstatus(ret);
22228
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_out("okay.");
22229
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_eol();
22230 457 break;
22231
22232 case ID_DOORS:
22233
22234 //door combo sets
22235
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
457 if(catchup)
22236 {
22237 box_out("found.");
22238 box_eol();
22239 catchup=false;
22240 }
22241
22242
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_out("Reading Doors...");
22243
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 ret=readdoorcombosets(f, &tempheader);
22244
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
457 checkstatus(ret);
22245
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_out("okay.");
22246
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_eol();
22247 457 break;
22248
22249 case ID_ITEMS:
22250
22251 //items
22252
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
457 if(catchup)
22253 {
22254 box_out("found.");
22255 box_eol();
22256 catchup=false;
22257 }
22258
22259
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_out("Reading Items...");
22260
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 ret=readitems(f, tempheader.zelda_version, tempheader.build);
22261
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
457 checkstatus(ret);
22262
22263
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_out("okay.");
22264
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_eol();
22265 457 break;
22266
22267 case ID_WEAPONS:
22268
22269 //weapons
22270
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
457 if(catchup)
22271 {
22272 box_out("found.");
22273 box_eol();
22274 catchup=false;
22275 }
22276
22277
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_out("Reading Weapons...");
22278
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 ret=readweapons(f, &tempheader);
22279
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
457 checkstatus(ret);
22280
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_out("okay.");
22281
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_eol();
22282 457 break;
22283
22284 case ID_COLORS:
22285
22286 //misc. colors
22287
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 if(catchup)
22288 {
22289 box_out("found.");
22290 box_eol();
22291 catchup=false;
22292 }
22293
22294
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 box_out("Reading Misc. Colors...");
22295
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 ret=readmisccolors(f, &tempheader, Misc);
22296
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
398 checkstatus(ret);
22297
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 box_out("okay.");
22298
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 box_eol();
22299 398 break;
22300
22301 case ID_ICONS:
22302
22303 //game icons
22304
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 if(catchup)
22305 {
22306 box_out("found.");
22307 box_eol();
22308 catchup=false;
22309 }
22310
22311
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 box_out("Reading Game Icons...");
22312
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 ret=readgameicons(f, &tempheader, Misc);
22313
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
398 checkstatus(ret);
22314
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 box_out("okay.");
22315
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 box_eol();
22316 398 break;
22317
22318 case ID_INITDATA:
22319
22320 //initialization data
22321
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
457 if(catchup)
22322 {
22323 box_out("found.");
22324 box_eol();
22325 catchup=false;
22326 }
22327
22328
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_out("Reading Init. Data...");
22329
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 ret=readinitdata(f, &tempheader);
22330
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
457 checkstatus(ret);
22331
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_out("okay.");
22332
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_eol();
22333
22334
2/4
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 457 times.
457 if(!get_bit(skip_flags, skip_subscreens))
22335 {
22336
2/2
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 363 times.
457 if(subscr_mode!=ssdtMAX) //not using custom subscreens
22337 {
22338
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 setupsubscreens();
22339
22340
2/2
✓ Branch 0 taken 48128 times.
✓ Branch 1 taken 94 times.
48222 for(int32_t i=0; i<MAXDMAPS; ++i)
22341 {
22342 48128 int32_t type=DMaps[i].type&dmfTYPE;
22343
2/2
✓ Branch 0 taken 1086 times.
✓ Branch 1 taken 47042 times.
48128 DMaps[i].active_subscreen=(type == dmOVERW || type == dmBSOVERW)?0:1;
22344 48128 DMaps[i].passive_subscreen=(get_qr(qr_ENABLEMAGIC))?0:1;
22345 48128 }
22346 94 }
22347 457 }
22348
22349
2/4
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 457 times.
✗ Branch 3 not taken.
457 if(!get_bit(skip_flags, skip_sfx))
22350 {
22351 457 setupsfx();
22352 457 }
22353
22354
2/4
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 457 times.
✗ Branch 3 not taken.
457 if(!get_bit(skip_flags, skip_itemdropsets))
22355 {
22356
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 init_item_drop_sets();
22357 457 }
22358
22359
2/4
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 457 times.
457 if(!get_bit(skip_flags, skip_favorites))
22360 {
22361 457 init_favorites();
22362 457 }
22363
22364 457 break;
22365
22366 case ID_GUYS:
22367
22368 //guys
22369
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
457 if(catchup)
22370 {
22371 box_out("found.");
22372 box_eol();
22373 catchup=false;
22374 }
22375
22376
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_out("Reading Custom Guy Data...");
22377
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 ret=readguys(f, &tempheader);
22378
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
457 checkstatus(ret);
22379
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_out("okay.");
22380
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_eol();
22381 457 break;
22382
22383 case ID_HEROSPRITES:
22384
22385 //hero sprites
22386
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 if(catchup)
22387 {
22388 box_out("found.");
22389 box_eol();
22390 catchup=false;
22391 }
22392
22393
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 box_out("Reading Custom Hero Sprite Data...");
22394
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 ret=readherosprites(f, &tempheader);
22395
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
398 checkstatus(ret);
22396
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 box_out("okay.");
22397
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 box_eol();
22398 398 break;
22399
22400 case ID_SUBSCREEN:
22401
22402 //custom subscreens
22403
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 if(catchup)
22404 {
22405 box_out("found.");
22406 box_eol();
22407 catchup=false;
22408 }
22409
22410
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 box_out("Reading Custom Subscreen Data...");
22411
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 ret=readsubscreens(f);
22412
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
398 checkstatus(ret);
22413
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 box_out("okay.");
22414
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 box_eol();
22415 398 break;
22416
22417 case ID_FFSCRIPT:
22418
22419 //Freeform combo scripts
22420
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 if(catchup)
22421 {
22422 box_out("found.");
22423 box_eol();
22424 catchup=false;
22425 }
22426
22427
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 box_out("Reading FF Script Data...");
22428
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 ret=readffscript(f, &tempheader);
22429
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
398 checkstatus(ret);
22430
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 box_out("okay.");
22431
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 box_eol();
22432 398 break;
22433
22434 case ID_SFX:
22435
22436 //SFX data
22437
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 if(catchup)
22438 {
22439 box_out("found.");
22440 box_eol();
22441 catchup=false;
22442 }
22443
22444
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 box_out("Reading SFX Data...");
22445
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 ret=readsfx(f, &tempheader);
22446
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
398 checkstatus(ret);
22447
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 box_out("okay.");
22448
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 box_eol();
22449 398 break;
22450
22451 case ID_MIDIS:
22452
22453 //midis
22454
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
457 if(catchup)
22455 {
22456 box_out("found.");
22457 box_eol();
22458 catchup=false;
22459 }
22460
22461
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_out("Reading Tunes...");
22462
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 ret=readtunes(f, &tempheader, tunes);
22463
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
457 checkstatus(ret);
22464
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_out("okay.");
22465
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_eol();
22466 457 break;
22467
22468 case ID_CHEATS:
22469
22470 //cheat codes
22471
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
457 if(catchup)
22472 {
22473 box_out("found.");
22474 box_eol();
22475 catchup=false;
22476 }
22477
22478
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_out("Reading Cheat Codes...");
22479
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 ret=readcheatcodes(f, &tempheader);
22480
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
457 checkstatus(ret);
22481
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_out("okay.");
22482
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_eol();
22483 457 break;
22484
22485 case ID_ITEMDROPSETS:
22486
22487 //item drop sets
22488
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 if(catchup)
22489 {
22490 box_out("found.");
22491 box_eol();
22492 catchup=false;
22493 }
22494
22495
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 box_out("Reading Item Drop Sets...");
22496
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 ret=readitemdropsets(f, tempheader.zelda_version);
22497
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
398 checkstatus(ret);
22498
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 box_out("okay.");
22499
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 box_eol();
22500 398 break;
22501
22502 case ID_FAVORITES:
22503
22504 //favorite combos and combo aliases
22505
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 if(catchup)
22506 {
22507 box_out("found.");
22508 box_eol();
22509 catchup=false;
22510 }
22511
22512
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 box_out("Reading Favorite Combos...");
22513
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 ret=readfavorites(f, tempheader.zelda_version);
22514
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
398 checkstatus(ret);
22515
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 box_out("okay.");
22516
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 box_eol();
22517 398 break;
22518
22519 default:
22520 if(!catchup)
22521 {
22522 box_out("Bad token! Searching...");
22523 box_eol();
22524 }
22525
22526 catchup=true;
22527 break;
22528 }
22529
22530
22531
1/2
✓ Branch 0 taken 11406 times.
✗ Branch 1 not taken.
11406 if(catchup)
22532 {
22533 //section id
22534 section_id=(section_id<<8);
22535
22536 if(!p_getc(&tempbyte,f))
22537 {
22538 goto invalid;
22539 }
22540
22541 section_id+=tempbyte;
22542 }
22543
22544 else
22545 {
22546 //section id
22547
3/4
✓ Branch 0 taken 11406 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10949 times.
✓ Branch 3 taken 457 times.
11406 if(!pack_feof(f))
22548 {
22549
2/4
✓ Branch 0 taken 10949 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10949 times.
✗ Branch 3 not taken.
10949 if(!p_mgetl(&section_id,f))
22550 {
22551 goto invalid;
22552 }
22553 10949 }
22554 }
22555 }
22556
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 780 times.
780 }
22557 else
22558 {
22559
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 std::vector<std::tuple<std::string, int32_t, std::function<int32_t()>>> hardcoded_sections = {
22560
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Rules", ID_RULES, [&](){ return readrules(f, &tempheader); }},
22561
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Strings", ID_STRINGS, [&](){ return readstrings(f, &tempheader); }},
22562
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Doors", ID_DOORS, [&](){ return readdoorcombosets(f, &tempheader); }},
22563
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "DMaps", ID_DMAPS, [&](){ return readdmaps(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXDMAPS); }},
22564
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Misc. Data", ID_MISC, [&](){ return readmisc(f, &tempheader, Misc); }},
22565
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Items", ID_ITEMS, [&](){ return readitems(f, tempheader.zelda_version, tempheader.build); }},
22566
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Weapons", ID_WEAPONS, [&](){ return readweapons(f, &tempheader); }},
22567
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Custom Guy Data", ID_GUYS, [&](){ return readguys(f, &tempheader); }},
22568
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Maps", ID_MAPS, [&](){ return readmaps(f, &tempheader); }},
22569
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Combos", ID_COMBOS, [&](){ return readcombos(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXCOMBOS); }},
22570
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Color Data", ID_CSETS, [&](){ return readcolordata(f, Misc, tempheader.zelda_version, tempheader.build, 0, newerpdTOTAL); }},
22571
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Tiles", ID_TILES, [&](){ return readtiles(f, newtilebuf, &tempheader, tempheader.zelda_version, tempheader.build, 0, NEWMAXTILES, false); }},
22572
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Tunes", ID_MIDIS, [&](){ return readtunes(f, &tempheader, tunes); }},
22573
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Cheat Codes", ID_CHEATS, [&](){ return readcheatcodes(f, &tempheader); }},
22574
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Init. Data", ID_INITDATA, [&](){ return readinitdata(f, &tempheader); }},
22575
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Custom Hero Sprite Data", ID_HEROSPRITES, [&](){ return readherosprites2(f, -1); }},
22576
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Up Default Item Drop Sets", ID_ITEMDROPSETS, [&](){ return readitemdropsets(f, -1); }},
22577 };
22578
22579 24 legacy_skip_flags = skip_flags;
22580
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 408 times.
1250 for (auto& [desc, section_id, fn] : hardcoded_sections)
22581 {
22582
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 int section_enum = section_id_to_enum(section_id);
22583
2/4
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 408 times.
✗ Branch 3 not taken.
408 bool skip = section_enum >= 0 && get_bit(skip_flags, section_enum);
22584
2/2
✓ Branch 0 taken 392 times.
✓ Branch 1 taken 16 times.
408 if (skip)
22585 {
22586 // Nothing to read.
22587
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 15 times.
16 if (section_id == ID_RULES)
22588 1 continue;
22589
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 14 times.
15 if (section_id == ID_GUYS)
22590 1 continue;
22591
22592 // Haven't looked at how to skip these, because we don't need to currently: the only
22593 // usage of skip_flags currently is all off except: header and tiles (see `load_imagebuf`).
22594
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 13 times.
14 if (section_id == ID_MIDIS)
22595 1 continue;
22596
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 12 times.
13 if (section_id == ID_CHEATS)
22597 1 continue;
22598
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 11 times.
12 if (section_id == ID_INITDATA)
22599 1 continue;
22600
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 10 times.
11 if (section_id == ID_HEROSPRITES)
22601 1 continue;
22602
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 9 times.
10 if (section_id == ID_ITEMDROPSETS)
22603 1 continue;
22604 9 }
22605
22606 // Would be nice, but old sections mostly did not save section sizes. We could advance by
22607 // a specific amount, but it'd be a lot of work to get it right. So, for old quests, let's just
22608 // read all the sections even if requested to skip some.
22609 // if (int retval = maybe_skip_section(f, section_id, skip_flags); retval != qe_OK)
22610 // {
22611 // if (retval == qe_cancel)
22612 // continue;
22613 // checkstatus(retval);
22614 // }
22615
22616
3/6
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 401 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 401 times.
✗ Branch 5 not taken.
802 box_out(fmt::format("Reading {}...", desc).c_str());
22617
1/2
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
401 ret = fn();
22618
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 401 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
401 checkstatus(ret);
22619
1/2
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
401 box_out("okay.");
22620
1/2
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
401 box_eol();
22621 }
22622 24 legacy_skip_flags = nullptr;
22623
22624
3/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✓ Branch 3 taken 1 times.
24 if(!get_bit(skip_flags, skip_subscreens))
22625 {
22626
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 setupsubscreens();
22627
22628
2/2
✓ Branch 0 taken 11776 times.
✓ Branch 1 taken 23 times.
11799 for(int32_t i=0; i<MAXDMAPS; ++i)
22629 {
22630 11776 int32_t type=DMaps[i].type&dmfTYPE;
22631
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 11732 times.
11776 DMaps[i].active_subscreen=(type == dmOVERW || type == dmBSOVERW)?0:1;
22632 11776 DMaps[i].passive_subscreen=(get_qr(qr_ENABLEMAGIC))?0:1;
22633 11776 }
22634 23 }
22635
22636
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 box_out("Setting Up Default Sound Effects...");
22637
22638
3/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 23 times.
24 if(!get_bit(skip_flags, skip_sfx))
22639 23 setupsfx();
22640
22641
3/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✓ Branch 3 taken 1 times.
24 if(!get_bit(skip_flags, skip_favorites))
22642 23 init_favorites();
22643
22644
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 box_out("okay.");
22645
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 box_eol();
22646
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
24 }
22647
22648
1/2
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
804 init_spritelists();
22649
22650 // check data
22651
1/2
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
804 if(f)
22652 {
22653
1/2
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
804 pack_fclose(f);
22654 804 }
22655
1/2
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
804 clear_quest_tmpfile();
22656
22657
1/2
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
804 if(!oldquest)
22658 {
22659
2/4
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 804 times.
804 if(exists(tmpfilename))
22660 {
22661 delete_file(tmpfilename);
22662 }
22663 804 }
22664
22665
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 804 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
804 if(fixffcs && combosread && mapsread)
22666 {
22667 for(int32_t i=0; i<map_count; i++)
22668 {
22669 for(int32_t j=0; j<MAPSCRS; j++)
22670 {
22671 int c = TheMaps[(i*MAPSCRS)+j].numFFC();
22672 for(int32_t m=0; m<c; m++)
22673 {
22674 if(combobuf[TheMaps[(i*MAPSCRS)+j].ffcs[m].data].type == cCHANGE)
22675 TheMaps[(i*MAPSCRS)+j].ffcs[m].flags|=ffc_changer;
22676 }
22677 }
22678 }
22679 }
22680
22681
3/4
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 480 times.
✓ Branch 3 taken 324 times.
804 if (!get_bit(skip_flags, skip_rules))
22682 {
22683
1/2
✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
480 bool should_hide = compat_qr_hide_bottom_pixels(tempheader);
22684
1/2
✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
480 al_trace("Note: qr_HIDE_BOTTOM_8_PIXELS %s via compat rule\n", should_hide ? "enabled" : "disabled");
22685
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 404 times.
480 if (should_hide)
22686
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 set_qr(qr_HIDE_BOTTOM_8_PIXELS, 1);
22687
22688
3/4
✓ Branch 0 taken 351 times.
✓ Branch 1 taken 129 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 351 times.
480 if (FFCore.quest_format[vCompatRule] < 77 && Header->is_z3)
22689 set_qr(qr_LAYER6_STRINGS_OVER_SUBSCREEN, 1);
22690 480 }
22691
22692
7/10
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 740 times.
✓ Branch 2 taken 64 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 63 times.
✓ Branch 5 taken 1 times.
✓ Branch 6 taken 63 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 63 times.
✗ Branch 9 not taken.
804 if(get_qr(qr_CONTFULL_DEP) && !get_bit(skip_flags, skip_rules) && !get_bit(skip_flags, skip_initdata))
22693 {
22694
1/2
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
63 set_qr(qr_CONTFULL_DEP, 0);
22695
1/2
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
63 zinit.flags.set(INIT_FL_CONTPERCENT,true);
22696 63 zinit.cont_heart=100;
22697 63 zinit.counter[crLIFE]=zinit.mcounter[crLIFE];
22698 63 }
22699
22700
1/2
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
804 box_out("Done.");
22701
1/2
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
804 box_eol();
22702
1/2
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
804 box_end(false);
22703
22704
3/4
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 481 times.
✓ Branch 3 taken 323 times.
804 if(!get_bit(skip_flags, skip_header))
22705 {
22706
1/2
✓ Branch 0 taken 481 times.
✗ Branch 1 not taken.
481 *Header = tempheader;
22707 481 }
22708
3/4
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 480 times.
✓ Branch 3 taken 324 times.
804 if(!get_bit(skip_flags, skip_zinfo))
22709 {
22710
1/2
✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
480 ZI.copyFrom(tempzi);
22711 480 }
22712
22713
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 804 times.
804 if(loading_tileset_flags & TILESET_CLEARMAPS)
22714 {
22715 TheMaps.clear();
22716 TheMaps.resize(MAPSCRS*1);
22717 map_count = 1;
22718 map_autolayers.clear();
22719 map_autolayers.resize(6*1);
22720 }
22721
22722
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 804 times.
804 if(loading_tileset_flags & TILESET_CLEARHEADER)
22723 {
22724 memset(Header->password, 0, sizeof(Header->password));
22725 memset(Header->minver, 0, sizeof(Header->minver));
22726 memset(Header->title, 0, sizeof(Header->title));
22727 memset(Header->author, 0, sizeof(Header->author));
22728 memset(Header->version, 0, sizeof(Header->version));
22729 Header->use_keyfile = 0;
22730 Header->dirty_password = false;
22731 cvs_MD5Context ctx;
22732 cvs_MD5Init(&ctx);
22733 cvs_MD5Update(&ctx, (const uint8_t*)"", 0);
22734 cvs_MD5Final(Header->pwd_hash, &ctx);
22735 }
22736
22737
3/4
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 480 times.
✓ Branch 3 taken 324 times.
804 if (!get_bit(skip_flags, skip_maps))
22738 {
22739 // Not needed, so release its memory.
22740
1/2
✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
480 old_combo_pages = {};
22741 480 }
22742
22743
2/2
✓ Branch 0 taken 324 times.
✓ Branch 1 taken 480 times.
804 if (skipping_any)
22744
1/2
✓ Branch 0 taken 324 times.
✗ Branch 1 not taken.
324 restore_prev_qstload_global_state();
22745
22746 804 return qe_OK;
22747
22748 invalid:
22749 // TODO: It's too easy to forget to jump to this label, and accidentally leave the file open.
22750 // Should wrap PACKFILE in a std::unique_pointer with a custom deallocator.
22751 box_out("error.");
22752 box_eol();
22753 box_end(true);
22754
22755 pack_fclose(f);
22756
22757 if(!oldquest)
22758 {
22759 if(exists(tmpfilename))
22760 {
22761 delete_file(tmpfilename);
22762 }
22763 }
22764
22765 restore_prev_qstload_global_state();
22766
22767 return qe_invalid;
22768
22769 804 }
22770
22771 static bool _is_loading_quest;
22772
22773 bool is_loading_quest()
22774 {
22775 return _is_loading_quest;
22776 }
22777
22778 323 std::string get_last_loaded_qstpath()
22779 {
22780 323 return last_loaded_qstpath;
22781 }
22782
22783 804 int32_t loadquest(const char *filename, zquestheader *Header, miscQdata *Misc,
22784 zctune *tunes, bool show_progress, byte *skip_flags, byte printmetadata,
22785 bool report, byte qst_num, dword tilesetflags)
22786 {
22787 804 loading_tileset_flags = tilesetflags;
22788 804 const char* basename = get_filename(filename);
22789 804 zapp_reporting_add_breadcrumb("load_quest", basename);
22790 804 zapp_reporting_set_tag("qst.filename", basename);
22791
22792 804 last_loaded_qstpath = filename;
22793 804 loading_qst_name = filename;
22794 804 loading_qst_num = qst_num;
22795 // In CI, builds are cached for replay tests, which can result in their build dates being earlier than what it would be locally.
22796 // So to avoid a more-recently updated .qst file from hitting the "last saved in a newer version" prompt, we disable in CI.
22797
1/2
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
804 if (!is_ci())
22798 loadquest_report = report;
22799
22800 804 _is_loading_quest = true;
22801 804 auto start = std::chrono::steady_clock::now();
22802 804 zprint2("Loading qst: %s\n", filename);
22803 804 int32_t ret = _lq_int(filename, Header, Misc, tunes, show_progress, skip_flags, printmetadata);
22804 804 int32_t load_ms = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - start).count();
22805 804 zprint2("Time to load qst: %d ms\n", load_ms);
22806 804 _is_loading_quest = false;
22807
1/2
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
804 if (ret)
22808 zprint2("Error: %s\n", qst_error[ret]);
22809
22810
1/2
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
804 if(show_progress)
22811 {
22812 if(ret)
22813 {
22814 box_out("-- Error loading quest file! --");
22815 box_out(fmt::format("Error: {}", qst_error[ret]).c_str());
22816 box_end(true);
22817 }
22818 else box_end(false);
22819 }
22820
22821 804 load_tmp_zi = NULL;
22822 804 loading_qst_name = NULL;
22823 804 loadquest_report = false;
22824 804 loading_qst_num = 0;
22825
22826 804 zapp_reporting_set_tag("qst.author", Header->author);
22827 804 zapp_reporting_set_tag("qst.title", Header->title);
22828 804 zapp_reporting_set_tag("qst.zc_version", Header->getVerStr());
22829
22830 804 return ret;
22831 }
22832